thirdweb 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414 → 5.100.1

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 (228) 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/auth/useSiweAuth.js +1 -1
  22. package/dist/cjs/react/core/hooks/auth/useSiweAuth.js.map +1 -1
  23. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  24. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  25. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +42 -38
  26. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  27. package/dist/cjs/react/core/utils/wallet.js +15 -0
  28. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  29. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
  30. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +0 -9
  32. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js +1 -1
  34. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +0 -177
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -15
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -60
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  45. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +133 -0
  46. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  47. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  48. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  49. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  50. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  51. package/dist/cjs/version.js +1 -1
  52. package/dist/cjs/version.js.map +1 -1
  53. package/dist/esm/bridge/Buy.js +1 -1
  54. package/dist/esm/bridge/Onramp.js +147 -0
  55. package/dist/esm/bridge/Onramp.js.map +1 -0
  56. package/dist/esm/bridge/OnrampStatus.js +75 -0
  57. package/dist/esm/bridge/OnrampStatus.js.map +1 -0
  58. package/dist/esm/bridge/Sell.js +1 -1
  59. package/dist/esm/bridge/index.js +1 -0
  60. package/dist/esm/bridge/index.js.map +1 -1
  61. package/dist/esm/bridge/types/BridgeAction.js +2 -0
  62. package/dist/esm/bridge/types/BridgeAction.js.map +1 -0
  63. package/dist/esm/extensions/ens/resolve-l2-name.js +0 -2
  64. package/dist/esm/extensions/ens/resolve-l2-name.js.map +1 -1
  65. package/dist/esm/pay/buyWithFiat/getQuote.js +129 -33
  66. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  67. package/dist/esm/pay/buyWithFiat/getStatus.js +71 -20
  68. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  69. package/dist/esm/pay/utils/commonTypes.js +1 -1
  70. package/dist/esm/pay/utils/commonTypes.js.map +1 -1
  71. package/dist/esm/pay/utils/definitions.js +0 -10
  72. package/dist/esm/pay/utils/definitions.js.map +1 -1
  73. package/dist/esm/react/core/hooks/auth/useSiweAuth.js +1 -1
  74. package/dist/esm/react/core/hooks/auth/useSiweAuth.js.map +1 -1
  75. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  76. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  77. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +42 -38
  78. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  79. package/dist/esm/react/core/utils/wallet.js +15 -0
  80. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  81. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
  82. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +0 -9
  84. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js +1 -1
  86. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +4 -180
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  89. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +2 -16
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -59
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  97. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +130 -0
  98. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  99. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  100. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  101. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  102. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  103. package/dist/esm/version.js +1 -1
  104. package/dist/esm/version.js.map +1 -1
  105. package/dist/types/bridge/Buy.d.ts +1 -1
  106. package/dist/types/bridge/Onramp.d.ts +123 -0
  107. package/dist/types/bridge/Onramp.d.ts.map +1 -0
  108. package/dist/types/bridge/OnrampStatus.d.ts +108 -0
  109. package/dist/types/bridge/OnrampStatus.d.ts.map +1 -0
  110. package/dist/types/bridge/Sell.d.ts +1 -1
  111. package/dist/types/bridge/index.d.ts +6 -3
  112. package/dist/types/bridge/index.d.ts.map +1 -1
  113. package/dist/types/bridge/types/BridgeAction.d.ts +2 -0
  114. package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -0
  115. package/dist/types/bridge/types/Quote.d.ts +3 -65
  116. package/dist/types/bridge/types/Quote.d.ts.map +1 -1
  117. package/dist/types/bridge/types/Route.d.ts +35 -0
  118. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  119. package/dist/types/bridge/types/Token.d.ts +1 -0
  120. package/dist/types/bridge/types/Token.d.ts.map +1 -1
  121. package/dist/types/extensions/ens/resolve-l2-name.d.ts.map +1 -1
  122. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  123. package/dist/types/pay/buyWithFiat/getStatus.d.ts +1 -12
  124. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  125. package/dist/types/pay/utils/commonTypes.d.ts +1 -1
  126. package/dist/types/pay/utils/commonTypes.d.ts.map +1 -1
  127. package/dist/types/pay/utils/definitions.d.ts +0 -10
  128. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  129. package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts.map +1 -1
  130. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +1 -0
  131. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  132. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  133. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  134. package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
  135. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts +1 -30
  136. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts.map +1 -1
  137. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +2 -0
  138. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  139. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +2 -0
  140. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
  141. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts +0 -5
  142. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
  143. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts +1 -3
  144. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts.map +1 -1
  145. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +15 -0
  146. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -0
  147. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
  148. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +1 -0
  149. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
  150. package/dist/types/version.d.ts +1 -1
  151. package/dist/types/version.d.ts.map +1 -1
  152. package/package.json +15 -15
  153. package/src/bridge/Buy.ts +1 -1
  154. package/src/bridge/Onramp.test.ts +118 -0
  155. package/src/bridge/Onramp.ts +244 -0
  156. package/src/bridge/OnrampStatus.ts +133 -0
  157. package/src/bridge/Sell.ts +1 -1
  158. package/src/bridge/index.ts +11 -3
  159. package/src/bridge/types/BridgeAction.ts +1 -0
  160. package/src/bridge/types/Quote.ts +3 -65
  161. package/src/bridge/types/Route.ts +39 -0
  162. package/src/bridge/types/Token.ts +1 -0
  163. package/src/extensions/ens/resolve-l2-name.ts +0 -2
  164. package/src/pay/buyWithFiat/getQuote.ts +184 -33
  165. package/src/pay/buyWithFiat/getStatus.ts +101 -42
  166. package/src/pay/convert/cryptoToFiat.test.ts +7 -5
  167. package/src/pay/convert/fiatToCrypto.test.ts +6 -4
  168. package/src/pay/utils/commonTypes.ts +1 -1
  169. package/src/pay/utils/definitions.ts +0 -14
  170. package/src/react/core/hooks/auth/useSiweAuth.ts +1 -1
  171. package/src/react/core/hooks/pay/useBuyWithFiatStatus.ts +0 -2
  172. package/src/react/core/hooks/transaction/useSendTransaction.ts +48 -41
  173. package/src/react/core/utils/wallet.ts +15 -0
  174. package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
  175. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +0 -53
  176. package/src/react/web/ui/ConnectWallet/locale/en.ts +1 -1
  177. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +3 -510
  178. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +2 -12
  179. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +2 -0
  180. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +19 -20
  181. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -37
  182. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts +1 -95
  183. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts +0 -69
  184. package/src/react/web/ui/TransactionButton/DepositScreen.tsx +295 -0
  185. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +4 -3
  186. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +20 -1
  187. package/src/version.ts +1 -1
  188. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -37
  189. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  190. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -86
  191. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  192. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -25
  193. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  194. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -81
  195. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  196. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -17
  197. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  198. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  199. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -34
  200. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  201. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -83
  202. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  203. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -22
  204. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  205. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -78
  206. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  207. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -14
  208. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  209. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -2
  210. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  211. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts +0 -26
  212. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts.map +0 -1
  213. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +0 -16
  214. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +0 -1
  215. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +0 -23
  216. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +0 -1
  217. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +0 -14
  218. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +0 -1
  219. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +0 -14
  220. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +0 -1
  221. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +0 -10
  222. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +0 -1
  223. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +0 -142
  224. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +0 -170
  225. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +0 -63
  226. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +0 -138
  227. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +0 -45
  228. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +0 -12
@@ -217,7 +217,7 @@ async function quote(options) {
217
217
  * ```
218
218
  *
219
219
  * ## Sending the transactions
220
- * 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:
220
+ * 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:
221
221
  * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
222
222
  * - 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.
223
223
  * - 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,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.status = void 0;
4
+ exports.prepare = prepare;
5
+ const domains_js_1 = require("../utils/domains.js");
6
+ const fetch_js_1 = require("../utils/fetch.js");
7
+ const json_js_1 = require("../utils/json.js");
8
+ // export status within the Onramp module
9
+ var OnrampStatus_js_1 = require("./OnrampStatus.js");
10
+ Object.defineProperty(exports, "status", { enumerable: true, get: function () { return OnrampStatus_js_1.status; } });
11
+ /**
12
+ * Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { Bridge } from "thirdweb";
17
+ * import { ethereum } from "thirdweb/chains";
18
+ * import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils";
19
+ *
20
+ * const preparedOnramp = await Bridge.Onramp.prepare({
21
+ * client: thirdwebClient,
22
+ * onramp: "stripe",
23
+ * chainId: ethereum.id,
24
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
25
+ * receiver: "0x...", // receiver's address
26
+ * amount: toWei("10"), // 10 of the destination token
27
+ * // Optional params:
28
+ * // sender: "0x...", // sender's address
29
+ * // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to
30
+ * // onrampChainId: 1, // chain to initially onramp to
31
+ * // currency: "USD",
32
+ * // maxSteps: 2,
33
+ * // purchaseData: { customId: "123" }
34
+ * });
35
+ *
36
+ * console.log(preparedOnramp.link); // URL to redirect the user to
37
+ * console.log(preparedOnramp.currencyAmount); // Amount in fiat the user will pay
38
+ * ```
39
+ *
40
+ * This function returns a quote that might look like:
41
+ * ```typescript
42
+ * {
43
+ * id: "123e4567-e89b-12d3-a456-426614174000",
44
+ * link: "https://onramp.example.com/session?id=...",
45
+ * currency: "USD",
46
+ * currencyAmount: 10.52,
47
+ * destinationAmount: 10000000000000000000n, // 10 ETH if decimals 18
48
+ * timestamp: 1689812800,
49
+ * expiration: 1689842800,
50
+ * steps: [
51
+ * // ... further steps if any post-onramp swaps are needed
52
+ * ],
53
+ * intent: {
54
+ * onramp: "stripe",
55
+ * chainId: 1,
56
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
57
+ * receiver: "0x...",
58
+ * amount: "10000000000000000000"
59
+ * }
60
+ * }
61
+ * ```
62
+ *
63
+ * @param options - The options for preparing the onramp.
64
+ * @param options.client - Your thirdweb client.
65
+ * @param options.onramp - The onramp provider to use (e.g., "stripe", "coinbase", "transak").
66
+ * @param options.chainId - The destination chain ID.
67
+ * @param options.tokenAddress - The destination token address.
68
+ * @param options.receiver - The address that will receive the output token.
69
+ * @param [options.amount] - The desired token amount in wei.
70
+ * @param [options.purchaseData] - Arbitrary purchase data.
71
+ * @param [options.sender] - An optional address to associate as the onramp sender.
72
+ * @param [options.onrampTokenAddress] - The token to initially onramp to if the destination token is not supported by the provider.
73
+ * @param [options.onrampChainId] - The chain ID to initially onramp to if the destination chain is not supported.
74
+ * @param [options.currency] - The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD".
75
+ * @param [options.maxSteps] - Maximum number of post-onramp steps.
76
+ * @param [options.excludeChainIds] - Chain IDs to exclude from the route (string or array of strings).
77
+ *
78
+ * @returns A promise that resolves to the prepared onramp details, including the link and quote.
79
+ * @throws Will throw an error if there is an issue preparing the onramp.
80
+ * @bridge Onramp
81
+ * @beta
82
+ */
83
+ async function prepare(options) {
84
+ const { client, onramp, chainId, tokenAddress, receiver, amount, purchaseData, sender, onrampTokenAddress, onrampChainId, currency, maxSteps, excludeChainIds, } = options;
85
+ const clientFetch = (0, fetch_js_1.getClientFetch)(client);
86
+ const url = `${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/onramp/prepare`;
87
+ const apiRequestBody = {
88
+ onramp,
89
+ chainId: Number(chainId),
90
+ tokenAddress,
91
+ receiver,
92
+ };
93
+ if (amount !== undefined) {
94
+ apiRequestBody.amount = amount.toString();
95
+ }
96
+ if (purchaseData !== undefined) {
97
+ apiRequestBody.purchaseData = purchaseData;
98
+ }
99
+ if (sender !== undefined) {
100
+ apiRequestBody.sender = sender;
101
+ }
102
+ if (onrampTokenAddress !== undefined) {
103
+ apiRequestBody.onrampTokenAddress = onrampTokenAddress;
104
+ }
105
+ if (onrampChainId !== undefined) {
106
+ apiRequestBody.onrampChainId = Number(onrampChainId);
107
+ }
108
+ if (currency !== undefined) {
109
+ apiRequestBody.currency = currency;
110
+ }
111
+ if (maxSteps !== undefined) {
112
+ apiRequestBody.maxSteps = maxSteps;
113
+ }
114
+ if (excludeChainIds !== undefined) {
115
+ apiRequestBody.excludeChainIds = Array.isArray(excludeChainIds)
116
+ ? excludeChainIds.join(",")
117
+ : excludeChainIds;
118
+ }
119
+ const response = await clientFetch(url, {
120
+ method: "POST",
121
+ headers: {
122
+ "Content-Type": "application/json",
123
+ },
124
+ body: (0, json_js_1.stringify)(apiRequestBody),
125
+ });
126
+ if (!response.ok) {
127
+ const errorJson = await response.json();
128
+ throw new Error(`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`);
129
+ }
130
+ const { data } = await response.json();
131
+ // Transform amounts from string to bigint where appropriate
132
+ const transformedSteps = data.steps.map((step) => ({
133
+ ...step,
134
+ originAmount: BigInt(step.originAmount),
135
+ destinationAmount: BigInt(step.destinationAmount),
136
+ transactions: step.transactions.map((tx) => ({
137
+ ...tx,
138
+ value: tx.value ? BigInt(tx.value) : undefined,
139
+ })),
140
+ }));
141
+ const intentFromResponse = {
142
+ ...data.intent,
143
+ amount: data.intent.amount ? data.intent.amount : undefined,
144
+ };
145
+ return {
146
+ ...data,
147
+ destinationAmount: BigInt(data.destinationAmount),
148
+ steps: transformedSteps,
149
+ intent: intentFromResponse,
150
+ };
151
+ }
152
+ //# sourceMappingURL=Onramp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Onramp.js","sourceRoot":"","sources":["../../../src/bridge/Onramp.ts"],"names":[],"mappings":";;;AA+HA,0BAgGC;AA7ND,oDAAyD;AACzD,gDAAmD;AACnD,8CAA6C;AAI7C,yCAAyC;AACzC,qDAA2C;AAAlC,yGAAA,MAAM,OAAA;AA8Cf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACI,KAAK,UAAU,OAAO,CAC3B,OAAwB;IAExB,MAAM,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,Y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ACd,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KAC5D,CAAC;IAEF,OAAO;QACL,GAAG,IAAI;QACP,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACjD,KAAK,EAAE,gBAAgB;QACvB,MAAM,EAAE,kBAAkB;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.status = status;
4
+ const domains_js_1 = require("../utils/domains.js");
5
+ const fetch_js_1 = require("../utils/fetch.js");
6
+ /**
7
+ * Retrieves the status of an Onramp session created via {@link Bridge.Onramp.prepare}. The
8
+ * status will include any on-chain transactions that have occurred as a result of the onramp
9
+ * as well as any arbitrary `purchaseData` that was supplied when the onramp was
10
+ * prepared.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Bridge } from "thirdweb";
15
+ *
16
+ * const onrampStatus = await Bridge.Onramp.status({
17
+ * id: "022218cc-96af-4291-b90c-dadcb47571ec",
18
+ * client: thirdwebClient,
19
+ * });
20
+ *
21
+ * // Possible results:
22
+ * // {
23
+ * // status: "CREATED",
24
+ * // transactions: [],
25
+ * // purchaseData: {
26
+ * // orderId: "abc-123",
27
+ * // },
28
+ * // }
29
+ * //
30
+ * // or
31
+ * // {
32
+ * // status: "PENDING",
33
+ * // transactions: [],
34
+ * // purchaseData: {
35
+ * // orderId: "abc-123",
36
+ * // },
37
+ * // }
38
+ * //
39
+ * // or
40
+ * // {
41
+ * // status: "COMPLETED",
42
+ * // transactions: [
43
+ * // {
44
+ * // chainId: 1,
45
+ * // transactionHash:
46
+ * // "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
47
+ * // },
48
+ * // ],
49
+ * // purchaseData: {
50
+ * // orderId: "abc-123",
51
+ * // },
52
+ * // }
53
+ * ```
54
+ *
55
+ * @param options - The options for fetching the onramp status.
56
+ * @param options.id - The UUID returned from {@link Bridge.Onramp.prepare}.
57
+ * @param options.client - Your thirdweb client instance.
58
+ *
59
+ * @returns A promise that resolves to the status of the onramp session.
60
+ *
61
+ * @throws Will throw an error if there is an issue fetching the status.
62
+ * @bridge Onramp
63
+ * @beta
64
+ */
65
+ async function status(options) {
66
+ const { id, client } = options;
67
+ const clientFetch = (0, fetch_js_1.getClientFetch)(client);
68
+ const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/onramp/status`);
69
+ url.searchParams.set("id", id);
70
+ const response = await clientFetch(url.toString());
71
+ if (!response.ok) {
72
+ const errorJson = await response.json();
73
+ throw new Error(`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`);
74
+ }
75
+ const { data } = await response.json();
76
+ return data;
77
+ }
78
+ //# sourceMappingURL=OnrampStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnrampStatus.js","sourceRoot":"","sources":["../../../src/bridge/OnrampStatus.ts"],"names":[],"mappings":";;AAgEA,wBAiBC;AA/ED,oDAAyD;AACzD,gDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACI,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE/B,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAA,+BAAkB,EAAC,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"}
@@ -215,7 +215,7 @@ async function quote(options) {
215
215
  * ```
216
216
  *
217
217
  * ## Sending the transactions
218
- * 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:
218
+ * 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:
219
219
  * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
220
220
  * - 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.
221
221
  * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chains = exports.routes = exports.status = exports.Transfer = exports.Sell = exports.Buy = void 0;
3
+ exports.chains = exports.routes = exports.status = exports.Onramp = exports.Transfer = exports.Sell = exports.Buy = void 0;
4
4
  exports.Buy = require("./Buy.js");
5
5
  exports.Sell = require("./Sell.js");
6
6
  exports.Transfer = require("./Transfer.js");
7
+ exports.Onramp = require("./Onramp.js");
7
8
  var Status_js_1 = require("./Status.js");
8
9
  Object.defineProperty(exports, "status", { enumerable: true, get: function () { return Status_js_1.status; } });
9
10
  var Routes_js_1 = require("./Routes.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":";;;AAAA,kCAAgC;AAChC,oCAAkC;AAClC,4CAA0C;AAC1C,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":";;;AAAA,kCAAgC;AAChC,oCAAkC;AAClC,4CAA0C;AAC1C,wCAAsC;AACtC,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=useBuyTransactionsToShow.js.map
3
+ //# sourceMappingURL=BridgeAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BridgeAction.js","sourceRoot":"","sources":["../../../../src/bridge/types/BridgeAction.ts"],"names":[],"mappings":""}
@@ -6,7 +6,6 @@ const ox__Bytes = require("ox/Bytes");
6
6
  const ox__Ens = require("ox/Ens");
7
7
  const ox__Hash = require("ox/Hash");
8
8
  const ox__Hex = require("ox/Hex");
9
- const viem_1 = require("viem");
10
9
  const contract_js_1 = require("../../contract/contract.js");
11
10
  const withCache_js_1 = require("../../utils/promise/withCache.js");
12
11
  const name_js_1 = require("./__generated__/L2Resolver/read/name.js");
@@ -23,7 +22,6 @@ const convertReverseNodeToBytes = (address, chainId) => {
23
22
  const chainCoinType = cointype.toString(16).toLocaleUpperCase();
24
23
  const reverseNode = ox__Ens.namehash(`${chainCoinType.toLocaleUpperCase()}.reverse`);
25
24
  const addressReverseNode = ox__Hash.keccak256(ox__AbiParameters.encodePacked(["bytes32", "bytes32"], [reverseNode, addressNode]));
26
- viem_1.keccak256;
27
25
  return addressReverseNode;
28
26
  };
29
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-l2-name.js","sourceRoot":"","sources":["../../../../src/extensions/ens/resolve-l2-name.ts"],"names":[],"mappings":";;AAiFA,sCAsCC;AAtHD,sDAAsD;AACtD,sCAAsC;AACtC,kCAAkC;AAClC,oCAAoC;AACpC,kCAAkC;AAClC,+BAAiC;AAGjC,4DAAyD;AACzD,mEAA6D;AAC7D,qEAA+D;AAY/D;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,CAAC,OAAgB,EAAE,OAAe,EAAE,EAAE;IACtE,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,EAAa,CAAC;IAChE,oFAAoF;IACpF,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CACnC,QAAQ,CAAC,SAAS,CAChB,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAC1D,CACF,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAChE,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAClC,GAAG,aAAa,CAAC,iBAAiB,EAAE,UAAU,CAC/C,CAAC;IAEF,MAAM,kBAAkB,GAAG,QAAQ,CAAC,SAAS,CAC3C,iBAAiB,CAAC,YAAY,CAC5B,CAAC,SAAS,EAAE,SAAS,CAAC,EACtB,CAAC,WAAW,EAAE,WAAW,CAAC,CAC3B,CACF,CAAC;IACF,gBAAS,CAAC;IACV,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,aAAa,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C,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,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBuyWithFiatQuote = getBuyWithFiatQuote;
4
- const fetch_js_1 = require("../../utils/fetch.js");
5
- const json_js_1 = require("../../utils/json.js");
6
- const definitions_js_1 = require("../utils/definitions.js");
4
+ const Onramp_js_1 = require("../../bridge/Onramp.js");
5
+ const utils_js_1 = require("../../chains/utils.js");
6
+ const addresses_js_1 = require("../../constants/addresses.js");
7
+ const contract_js_1 = require("../../contract/contract.js");
8
+ const decimals_js_1 = require("../../extensions/erc20/read/decimals.js");
9
+ const units_js_1 = require("../../utils/units.js");
7
10
  /**
8
11
  * Get a quote of type [`BuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatQuote) to buy given token with fiat currency.
9
12
  * This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.
@@ -54,38 +57,131 @@ const definitions_js_1 = require("../utils/definitions.js");
54
57
  */
55
58
  async function getBuyWithFiatQuote(params) {
56
59
  try {
57
- const clientFetch = (0, fetch_js_1.getClientFetch)(params.client);
58
- const response = await clientFetch((0, definitions_js_1.getPayBuyWithFiatQuoteEndpoint)(), {
59
- method: "POST",
60
- headers: {
61
- Accept: "application/json",
62
- "Content-Type": "application/json",
63
- },
64
- body: (0, json_js_1.stringify)({
65
- toAddress: params.toAddress,
66
- fromCurrencySymbol: params.fromCurrencySymbol,
67
- toChainId: params.toChainId.toString(),
68
- toTokenAddress: params.toTokenAddress,
69
- fromAmount: params.fromAmount,
70
- toAmount: params.toAmount,
71
- maxSlippageBPS: params.maxSlippageBPS,
72
- isTestMode: params.isTestMode,
73
- purchaseData: params.purchaseData,
74
- fromAddress: params.fromAddress,
75
- toGasAmountWei: params.toGasAmountWei,
76
- preferredProvider: params.preferredProvider,
77
- multiHopSupported: true,
78
- }),
79
- });
80
- // Assuming the response directly matches the SwapResponse interface
81
- if (!response.ok) {
82
- const errorObj = await response.json();
83
- if (errorObj && "error" in errorObj) {
84
- throw errorObj;
60
+ // map preferred provider (FiatProvider) → onramp string expected by Onramp.prepare
61
+ const mapProviderToOnramp = (provider) => {
62
+ switch (provider) {
63
+ case "STRIPE":
64
+ return "stripe";
65
+ case "TRANSAK":
66
+ return "transak";
67
+ default: // default to coinbase when undefined or any other value
68
+ return "coinbase";
85
69
  }
86
- throw new Error(`HTTP error! status: ${response.status}`);
70
+ };
71
+ // Choose provider or default to STRIPE
72
+ const onrampProvider = mapProviderToOnramp(params.preferredProvider);
73
+ const d = params.toTokenAddress !== addresses_js_1.NATIVE_TOKEN_ADDRESS
74
+ ? await (0, decimals_js_1.decimals)({
75
+ contract: (0, contract_js_1.getContract)({
76
+ client: params.client,
77
+ address: params.toTokenAddress,
78
+ chain: (0, utils_js_1.getCachedChain)(params.toChainId),
79
+ }),
80
+ })
81
+ : 18;
82
+ // Prepare amount in wei if provided
83
+ const amountWei = params.toAmount ? (0, units_js_1.toUnits)(params.toAmount, d) : undefined;
84
+ // Call new Onramp.prepare to get the quote & link
85
+ const prepared = await (0, Onramp_js_1.prepare)({
86
+ client: params.client,
87
+ onramp: onrampProvider,
88
+ chainId: params.toChainId,
89
+ tokenAddress: params.toTokenAddress,
90
+ receiver: params.toAddress,
91
+ sender: params.fromAddress,
92
+ amount: amountWei,
93
+ purchaseData: params.purchaseData,
94
+ currency: params.fromCurrencySymbol,
95
+ maxSteps: 2,
96
+ onrampTokenAddress: addresses_js_1.NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
97
+ });
98
+ // Determine tokens based on steps rules
99
+ const hasSteps = prepared.steps.length > 0;
100
+ const firstStep = hasSteps
101
+ ? prepared.steps[0]
102
+ : undefined;
103
+ // Estimated duration in seconds – sum of all step durations
104
+ const estimatedDurationSeconds = Math.max(120, Math.ceil(prepared.steps.reduce((acc, s) => acc + s.estimatedExecutionTimeMs, 0) /
105
+ 1000));
106
+ const estimatedToAmountMinWeiBigInt = prepared.destinationAmount;
107
+ const maxSlippageBPS = params.maxSlippageBPS ?? 0;
108
+ const slippageWei = (estimatedToAmountMinWeiBigInt * BigInt(maxSlippageBPS)) / 10000n;
109
+ const toAmountMinWeiBigInt = estimatedToAmountMinWeiBigInt - slippageWei;
110
+ const estimatedToAmountMin = (0, units_js_1.toTokens)(estimatedToAmountMinWeiBigInt, d);
111
+ const toAmountMin = (0, units_js_1.toTokens)(toAmountMinWeiBigInt, d);
112
+ // Helper to convert a Token → PayTokenInfo
113
+ const tokenToPayTokenInfo = (token) => ({
114
+ chainId: token.chainId,
115
+ tokenAddress: token.address,
116
+ decimals: token.decimals,
117
+ priceUSDCents: Math.round(token.priceUsd * 100),
118
+ name: token.name,
119
+ symbol: token.symbol,
120
+ });
121
+ // Determine the raw token objects using new simplified rules
122
+ // 1. toToken is always the destination token
123
+ const toTokenRaw = prepared.destinationToken;
124
+ // 2. onRampToken: if exactly one step -> originToken of that step, else toTokenRaw
125
+ const onRampTokenRaw = prepared.steps.length > 0 && firstStep
126
+ ? firstStep.originToken
127
+ : toTokenRaw;
128
+ // 3. routingToken: if exactly two steps -> originToken of second step, else undefined
129
+ const routingTokenRaw = prepared.steps.length > 1
130
+ ? prepared.steps[1].originToken
131
+ : undefined;
132
+ // Amounts for onRampToken/raw
133
+ const onRampTokenAmountWei = prepared.steps.length > 0 && firstStep
134
+ ? firstStep.originAmount
135
+ : prepared.destinationAmount;
136
+ const onRampTokenAmount = (0, units_js_1.toTokens)(onRampTokenAmountWei, onRampTokenRaw.decimals);
137
+ // Build info objects
138
+ const onRampTokenObject = {
139
+ amount: onRampTokenAmount,
140
+ amountWei: onRampTokenAmountWei.toString(),
141
+ amountUSDCents: Math.round(Number(onRampTokenAmount) * onRampTokenRaw.priceUsd * 100),
142
+ token: tokenToPayTokenInfo(onRampTokenRaw),
143
+ };
144
+ let routingTokenObject;
145
+ if (routingTokenRaw) {
146
+ const routingAmountWei = prepared.steps[1].originAmount;
147
+ const routingAmount = (0, units_js_1.toTokens)(routingAmountWei, routingTokenRaw.decimals);
148
+ routingTokenObject = {
149
+ amount: routingAmount,
150
+ amountWei: routingAmountWei.toString(),
151
+ amountUSDCents: Math.round(Number(routingAmount) * routingTokenRaw.priceUsd * 100),
152
+ token: tokenToPayTokenInfo(routingTokenRaw),
153
+ };
87
154
  }
88
- return (await response.json()).result;
155
+ const buyWithFiatQuote = {
156
+ estimatedDurationSeconds,
157
+ estimatedToAmountMin: estimatedToAmountMin,
158
+ estimatedToAmountMinWei: estimatedToAmountMinWeiBigInt.toString(),
159
+ toAmountMinWei: toAmountMinWeiBigInt.toString(),
160
+ toAmountMin: toAmountMin,
161
+ fromCurrency: {
162
+ amount: prepared.currencyAmount.toString(),
163
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
164
+ decimals: 2,
165
+ currencySymbol: prepared.currency,
166
+ },
167
+ fromCurrencyWithFees: {
168
+ amount: prepared.currencyAmount.toString(),
169
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
170
+ decimals: 2,
171
+ currencySymbol: prepared.currency,
172
+ },
173
+ toToken: tokenToPayTokenInfo(toTokenRaw),
174
+ toAddress: params.toAddress,
175
+ fromAddress: params.fromAddress,
176
+ maxSlippageBPS: maxSlippageBPS,
177
+ intentId: prepared.id,
178
+ processingFees: [],
179
+ onRampToken: onRampTokenObject,
180
+ routingToken: routingTokenObject,
181
+ onRampLink: prepared.link,
182
+ provider: (params.preferredProvider ?? "COINBASE"),
183
+ };
184
+ return buyWithFiatQuote;
89
185
  }
90
186
  catch (error) {
91
187
  console.error("Error getting buy with fiat quote", error);
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/pay/buyWithFiat/getQuote.ts"],"names":[],"mappings":";;AAgRA,kDA2CC;AAzTD,mDAAsD;AACtD,iDAAgD;AAEhD,4DAAyE;AA2NzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAiC;IAEjC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAA,+CAA8B,GAAE,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAA,mBAAS,EAAC;gBACd,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;gBAC7C,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,cAAc;gBACrC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,iBAAiB,EAAE,IAAI;aAC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";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBuyWithFiatStatus = getBuyWithFiatStatus;
4
- const fetch_js_1 = require("../../utils/fetch.js");
5
- const definitions_js_1 = require("../utils/definitions.js");
4
+ const OnrampStatus_js_1 = require("../../bridge/OnrampStatus.js");
6
5
  /**
7
6
  * Once you get a `quote` from [`getBuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatQuote)
8
7
  * and open the `quote.onRampLink` in a new tab, you can start polling for the transaction status using `getBuyWithFiatStatus`
@@ -41,28 +40,80 @@ const definitions_js_1 = require("../utils/definitions.js");
41
40
  * })
42
41
  *
43
42
  * // when the fiatStatus.status is "ON_RAMP_TRANSFER_COMPLETED" - the process is complete
44
- * // when the fiatStatus.status is "CRYPTO_SWAP_REQUIRED" - start the swap process
45
43
  * ```
46
44
  * @deprecated
47
45
  * @buyCrypto
48
46
  */
49
47
  async function getBuyWithFiatStatus(params) {
50
- try {
51
- const queryParams = new URLSearchParams({
52
- intentId: params.intentId,
53
- });
54
- const queryString = queryParams.toString();
55
- const url = `${(0, definitions_js_1.getPayBuyWithFiatStatusEndpoint)()}?${queryString}`;
56
- const response = await (0, fetch_js_1.getClientFetch)(params.client)(url);
57
- if (!response.ok) {
58
- const error = await response.text().catch(() => null);
59
- throw new Error(`HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`);
60
- }
61
- return (await response.json()).result;
62
- }
63
- catch (error) {
64
- console.error("Fetch error:", error);
65
- throw new Error(`Fetch failed: ${error}`);
66
- }
48
+ const result = await (0, OnrampStatus_js_1.status)({
49
+ id: params.intentId,
50
+ client: params.client,
51
+ });
52
+ return toBuyWithFiatStatus({ intentId: params.intentId, result });
53
+ }
54
+ ////////////////////////////////////////////////////////////////////////////////
55
+ // Helpers
56
+ ////////////////////////////////////////////////////////////////////////////////
57
+ function toBuyWithFiatStatus(args) {
58
+ const { intentId, result } = args;
59
+ // Map status constants from the Bridge.Onramp.status response to BuyWithFiatStatus equivalents.
60
+ const STATUS_MAP = {
61
+ CREATED: "PENDING_PAYMENT",
62
+ PENDING: "PENDING_PAYMENT",
63
+ FAILED: "PAYMENT_FAILED",
64
+ COMPLETED: "ON_RAMP_TRANSFER_COMPLETED",
65
+ };
66
+ const mappedStatus = STATUS_MAP[result.status];
67
+ return buildPlaceholderStatus({
68
+ intentId,
69
+ status: mappedStatus,
70
+ purchaseData: result.purchaseData,
71
+ });
72
+ }
73
+ function buildPlaceholderStatus(args) {
74
+ const { intentId, status, purchaseData } = args;
75
+ // Build a minimal—but type-complete—object that satisfies BuyWithFiatStatus.
76
+ const emptyToken = {
77
+ chainId: 0,
78
+ tokenAddress: "",
79
+ decimals: 18,
80
+ priceUSDCents: 0,
81
+ name: "",
82
+ symbol: "",
83
+ };
84
+ const quote = {
85
+ estimatedOnRampAmount: "0",
86
+ estimatedOnRampAmountWei: "0",
87
+ estimatedToTokenAmount: "0",
88
+ estimatedToTokenAmountWei: "0",
89
+ fromCurrency: {
90
+ amount: "0",
91
+ amountUnits: "USD",
92
+ decimals: 2,
93
+ currencySymbol: "USD",
94
+ },
95
+ fromCurrencyWithFees: {
96
+ amount: "0",
97
+ amountUnits: "USD",
98
+ decimals: 2,
99
+ currencySymbol: "USD",
100
+ },
101
+ onRampToken: emptyToken,
102
+ toToken: emptyToken,
103
+ estimatedDurationSeconds: 0,
104
+ createdAt: new Date().toISOString(),
105
+ };
106
+ // The source/destination fields can only be filled accurately when extra context is returned
107
+ // by the API. Since Bridge.Onramp.status doesn't yet provide these details, we omit them for
108
+ // now (they are optional).
109
+ const base = {
110
+ intentId,
111
+ status,
112
+ toAddress: "",
113
+ fromAddress: "",
114
+ quote,
115
+ purchaseData: purchaseData,
116
+ };
117
+ return base;
67
118
  }
68
119
  //# sourceMappingURL=getStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStatus.js","sourceRoot":"","sources":["../../../../src/pay/buyWithFiat/getStatus.ts"],"names":[],"mappings":";;AAkLA,o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