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
@@ -0,0 +1,133 @@
1
+ import type { Hex as ox__Hex } from "ox";
2
+ import type { ThirdwebClient } from "../client/client.js";
3
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
4
+ import { getClientFetch } from "../utils/fetch.js";
5
+
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
+ export async function status(options: status.Options): Promise<status.Result> {
66
+ const { id, client } = options;
67
+
68
+ const clientFetch = getClientFetch(client);
69
+ const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/onramp/status`);
70
+ url.searchParams.set("id", id);
71
+
72
+ const response = await clientFetch(url.toString());
73
+ if (!response.ok) {
74
+ const errorJson = await response.json();
75
+ throw new Error(
76
+ `${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`,
77
+ );
78
+ }
79
+
80
+ const { data }: { data: status.Result } = await response.json();
81
+ return data;
82
+ }
83
+
84
+ export declare namespace status {
85
+ /**
86
+ * Input parameters for {@link Bridge.Onramp.status}.
87
+ */
88
+ export type Options = {
89
+ /**
90
+ * The Onramp session ID returned by {@link Bridge.Onramp.prepare}.
91
+ */
92
+ id: string;
93
+ /** Your {@link ThirdwebClient} instance. */
94
+ client: ThirdwebClient;
95
+ };
96
+
97
+ /**
98
+ * The result returned from {@link Bridge.Onramp.status}.
99
+ */
100
+ export type Result =
101
+ | {
102
+ status: "COMPLETED";
103
+ transactions: Array<{
104
+ chainId: number;
105
+ transactionHash: ox__Hex.Hex;
106
+ }>;
107
+ purchaseData?: unknown;
108
+ }
109
+ | {
110
+ status: "PENDING";
111
+ transactions: Array<{
112
+ chainId: number;
113
+ transactionHash: ox__Hex.Hex;
114
+ }>;
115
+ purchaseData?: unknown;
116
+ }
117
+ | {
118
+ status: "CREATED";
119
+ transactions: Array<{
120
+ chainId: number;
121
+ transactionHash: ox__Hex.Hex;
122
+ }>;
123
+ purchaseData?: unknown;
124
+ }
125
+ | {
126
+ status: "FAILED";
127
+ transactions: Array<{
128
+ chainId: number;
129
+ transactionHash: ox__Hex.Hex;
130
+ }>;
131
+ purchaseData?: unknown;
132
+ };
133
+ }
@@ -251,7 +251,7 @@ export declare namespace quote {
251
251
  * ```
252
252
  *
253
253
  * ## Sending the transactions
254
- * 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:
254
+ * 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:
255
255
  * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
256
256
  * - 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.
257
257
  * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
@@ -1,11 +1,19 @@
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";
7
8
 
8
- export type { Status } from "./types/Status.js";
9
- export type { Route } from "./types/Route.js";
10
- export type { Quote, PreparedQuote } from "./types/Quote.js";
11
9
  export type { Chain } from "./types/Chain.js";
10
+ export type { Quote, PreparedQuote } from "./types/Quote.js";
11
+ export type {
12
+ Route,
13
+ RouteQuoteStep,
14
+ RouteStep,
15
+ RouteTransaction,
16
+ } from "./types/Route.js";
17
+ export type { Status } from "./types/Status.js";
18
+ export type { Token } from "./types/Token.js";
19
+ export type { BridgeAction } from "./types/BridgeAction.js";
@@ -0,0 +1 @@
1
+ export type BridgeAction = "approval" | "transfer" | "buy" | "sell";
@@ -1,6 +1,4 @@
1
- import type { Hex as ox__Hex } from "ox";
2
- import type { Chain } from "../../chains/types.js";
3
- import type { ThirdwebClient } from "../../client/client.js";
1
+ import type { RouteQuoteStep, RouteStep } from "./Route.js";
4
2
 
5
3
  export type Quote = {
6
4
  /**
@@ -26,29 +24,7 @@ export type Quote = {
26
24
  /**
27
25
  * The steps required to complete the quote.
28
26
  */
29
- steps: Array<{
30
- originToken: {
31
- chainId: number;
32
- address: ox__Hex.Hex;
33
- symbol: string;
34
- name: string;
35
- decimals: number;
36
- priceUsd: number;
37
- iconUri: string;
38
- };
39
- destinationToken: {
40
- chainId: number;
41
- address: ox__Hex.Hex;
42
- symbol: string;
43
- name: string;
44
- decimals: number;
45
- priceUsd: number;
46
- iconUri: string;
47
- };
48
- originAmount: bigint;
49
- destinationAmount: bigint;
50
- estimatedExecutionTimeMs: number;
51
- }>;
27
+ steps: RouteQuoteStep[];
52
28
  };
53
29
 
54
30
  export type PreparedQuote = {
@@ -79,43 +55,5 @@ export type PreparedQuote = {
79
55
  /**
80
56
  * A series of steps required to complete the quote, along with the transactions to execute in order.
81
57
  */
82
- steps: Array<{
83
- originToken: {
84
- chainId: number;
85
- address: ox__Hex.Hex;
86
- symbol: string;
87
- name: string;
88
- decimals: number;
89
- priceUsd: number;
90
- iconUri: string;
91
- };
92
- destinationToken: {
93
- chainId: number;
94
- address: ox__Hex.Hex;
95
- symbol: string;
96
- name: string;
97
- decimals: number;
98
- priceUsd: number;
99
- iconUri: string;
100
- };
101
- originAmount: bigint;
102
- destinationAmount: bigint;
103
- estimatedExecutionTimeMs: number;
104
- transactions: Array<{
105
- data: ox__Hex.Hex;
106
- to: ox__Hex.Hex;
107
- value?: bigint | undefined;
108
- chainId: number;
109
- /**
110
- * The action this transaction performs. This can be "approval", "transfer", "buy", or "sell".
111
- */
112
- action: "approval" | "transfer" | "buy" | "sell";
113
- /**
114
- * The transaction ID, used for tracking purposes.
115
- */
116
- id: ox__Hex.Hex;
117
- client: ThirdwebClient;
118
- chain: Chain;
119
- }>;
120
- }>;
58
+ steps: RouteStep[];
121
59
  };
@@ -1,6 +1,45 @@
1
+ import type { Hex as ox__Hex } from "ox";
2
+ import type { Chain } from "../../chains/types.js";
3
+ import type { ThirdwebClient } from "../../client/client.js";
4
+ import type { BridgeAction } from "./BridgeAction.js";
1
5
  import type { Token } from "./Token.js";
2
6
 
3
7
  export type Route = {
4
8
  originToken: Token;
5
9
  destinationToken: Token;
6
10
  };
11
+
12
+ export type RouteQuoteStep = {
13
+ originToken: Token;
14
+ destinationToken: Token;
15
+ originAmount: bigint;
16
+ destinationAmount: bigint;
17
+ estimatedExecutionTimeMs: number;
18
+ };
19
+
20
+ export type RouteStep = {
21
+ originToken: Token;
22
+ destinationToken: Token;
23
+ originAmount: bigint;
24
+ destinationAmount: bigint;
25
+ estimatedExecutionTimeMs: number;
26
+ transactions: RouteTransaction[];
27
+ };
28
+
29
+ export type RouteTransaction = {
30
+ data: ox__Hex.Hex;
31
+ to: ox__Hex.Hex;
32
+ value?: bigint | undefined;
33
+ chainId: number;
34
+
35
+ /**
36
+ * The action this transaction performs. This can be "approval", "transfer", "buy", or "sell".
37
+ */
38
+ action: BridgeAction;
39
+ /**
40
+ * The transaction ID, used for tracking purposes.
41
+ */
42
+ id: ox__Hex.Hex;
43
+ client: ThirdwebClient;
44
+ chain: Chain;
45
+ };
@@ -7,4 +7,5 @@ export type Token = {
7
7
  symbol: string;
8
8
  name: string;
9
9
  iconUri?: string;
10
+ priceUsd: number;
10
11
  };
@@ -4,7 +4,6 @@ import * as ox__Bytes from "ox/Bytes";
4
4
  import * as ox__Ens from "ox/Ens";
5
5
  import * as ox__Hash from "ox/Hash";
6
6
  import * as ox__Hex from "ox/Hex";
7
- import { keccak256 } from "viem";
8
7
  import type { Chain } from "../../chains/types.js";
9
8
  import type { ThirdwebClient } from "../../client/client.js";
10
9
  import { getContract } from "../../contract/contract.js";
@@ -47,7 +46,6 @@ const convertReverseNodeToBytes = (address: Address, chainId: number) => {
47
46
  [reverseNode, addressNode],
48
47
  ),
49
48
  );
50
- keccak256;
51
49
  return addressReverseNode;
52
50
  };
53
51
 
@@ -1,9 +1,12 @@
1
+ import { prepare as prepareOnramp } from "../../bridge/Onramp.js";
2
+ import { getCachedChain } from "../../chains/utils.js";
1
3
  import type { ThirdwebClient } from "../../client/client.js";
4
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
5
+ import { getContract } from "../../contract/contract.js";
6
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
2
7
  import type { CurrencyMeta } from "../../react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js";
3
- import { getClientFetch } from "../../utils/fetch.js";
4
- import { stringify } from "../../utils/json.js";
8
+ import { toTokens, toUnits } from "../../utils/units.js";
5
9
  import type { FiatProvider, PayTokenInfo } from "../utils/commonTypes.js";
6
- import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
7
10
  /**
8
11
  * Parameters for [`getBuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatQuote) function
9
12
  * @deprecated
@@ -274,41 +277,189 @@ export async function getBuyWithFiatQuote(
274
277
  params: GetBuyWithFiatQuoteParams,
275
278
  ): Promise<BuyWithFiatQuote> {
276
279
  try {
277
- const clientFetch = getClientFetch(params.client);
280
+ // map preferred provider (FiatProvider) → onramp string expected by Onramp.prepare
281
+ const mapProviderToOnramp = (
282
+ provider?: FiatProvider,
283
+ ): "stripe" | "coinbase" | "transak" => {
284
+ switch (provider) {
285
+ case "STRIPE":
286
+ return "stripe";
287
+ case "TRANSAK":
288
+ return "transak";
289
+ default: // default to coinbase when undefined or any other value
290
+ return "coinbase";
291
+ }
292
+ };
278
293
 
279
- const response = await clientFetch(getPayBuyWithFiatQuoteEndpoint(), {
280
- method: "POST",
281
- headers: {
282
- Accept: "application/json",
283
- "Content-Type": "application/json",
284
- },
285
- body: stringify({
286
- toAddress: params.toAddress,
287
- fromCurrencySymbol: params.fromCurrencySymbol,
288
- toChainId: params.toChainId.toString(),
289
- toTokenAddress: params.toTokenAddress,
290
- fromAmount: params.fromAmount,
291
- toAmount: params.toAmount,
292
- maxSlippageBPS: params.maxSlippageBPS,
293
- isTestMode: params.isTestMode,
294
- purchaseData: params.purchaseData,
295
- fromAddress: params.fromAddress,
296
- toGasAmountWei: params.toGasAmountWei,
297
- preferredProvider: params.preferredProvider,
298
- multiHopSupported: true,
299
- }),
294
+ // Choose provider or default to STRIPE
295
+ const onrampProvider = mapProviderToOnramp(params.preferredProvider);
296
+
297
+ const d =
298
+ params.toTokenAddress !== NATIVE_TOKEN_ADDRESS
299
+ ? await decimals({
300
+ contract: getContract({
301
+ client: params.client,
302
+ address: params.toTokenAddress,
303
+ chain: getCachedChain(params.toChainId),
304
+ }),
305
+ })
306
+ : 18;
307
+
308
+ // Prepare amount in wei if provided
309
+ const amountWei = params.toAmount ? toUnits(params.toAmount, d) : undefined;
310
+
311
+ // Call new Onramp.prepare to get the quote & link
312
+ const prepared = await prepareOnramp({
313
+ client: params.client,
314
+ onramp: onrampProvider,
315
+ chainId: params.toChainId,
316
+ tokenAddress: params.toTokenAddress,
317
+ receiver: params.toAddress,
318
+ sender: params.fromAddress,
319
+ amount: amountWei,
320
+ purchaseData: params.purchaseData,
321
+ currency: params.fromCurrencySymbol,
322
+ maxSteps: 2,
323
+ onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
300
324
  });
301
325
 
302
- // Assuming the response directly matches the SwapResponse interface
303
- if (!response.ok) {
304
- const errorObj = await response.json();
305
- if (errorObj && "error" in errorObj) {
306
- throw errorObj;
307
- }
308
- throw new Error(`HTTP error! status: ${response.status}`);
326
+ // Determine tokens based on steps rules
327
+ const hasSteps = prepared.steps.length > 0;
328
+ const firstStep = hasSteps
329
+ ? (prepared.steps[0] as (typeof prepared.steps)[number])
330
+ : undefined;
331
+
332
+ // Estimated duration in seconds – sum of all step durations
333
+ const estimatedDurationSeconds = Math.max(
334
+ 120,
335
+ Math.ceil(
336
+ prepared.steps.reduce((acc, s) => acc + s.estimatedExecutionTimeMs, 0) /
337
+ 1000,
338
+ ),
339
+ );
340
+
341
+ const estimatedToAmountMinWeiBigInt = prepared.destinationAmount;
342
+
343
+ const maxSlippageBPS = params.maxSlippageBPS ?? 0;
344
+ const slippageWei =
345
+ (estimatedToAmountMinWeiBigInt * BigInt(maxSlippageBPS)) / 10000n;
346
+ const toAmountMinWeiBigInt = estimatedToAmountMinWeiBigInt - slippageWei;
347
+
348
+ const estimatedToAmountMin = toTokens(estimatedToAmountMinWeiBigInt, d);
349
+ const toAmountMin = toTokens(toAmountMinWeiBigInt, d);
350
+
351
+ // Helper to convert a Token → PayTokenInfo
352
+ const tokenToPayTokenInfo = (token: {
353
+ chainId: number;
354
+ address: string;
355
+ decimals: number;
356
+ symbol: string;
357
+ name: string;
358
+ priceUsd: number;
359
+ }): PayTokenInfo => ({
360
+ chainId: token.chainId,
361
+ tokenAddress: token.address,
362
+ decimals: token.decimals,
363
+ priceUSDCents: Math.round(token.priceUsd * 100),
364
+ name: token.name,
365
+ symbol: token.symbol,
366
+ });
367
+
368
+ // Determine the raw token objects using new simplified rules
369
+ // 1. toToken is always the destination token
370
+ const toTokenRaw = prepared.destinationToken;
371
+
372
+ // 2. onRampToken: if exactly one step -> originToken of that step, else toTokenRaw
373
+ const onRampTokenRaw =
374
+ prepared.steps.length > 0 && firstStep
375
+ ? firstStep.originToken
376
+ : toTokenRaw;
377
+
378
+ // 3. routingToken: if exactly two steps -> originToken of second step, else undefined
379
+ const routingTokenRaw =
380
+ prepared.steps.length > 1
381
+ ? (prepared.steps[1] as (typeof prepared.steps)[number]).originToken
382
+ : undefined;
383
+
384
+ // Amounts for onRampToken/raw
385
+ const onRampTokenAmountWei: bigint =
386
+ prepared.steps.length > 0 && firstStep
387
+ ? firstStep.originAmount
388
+ : prepared.destinationAmount;
389
+
390
+ const onRampTokenAmount = toTokens(
391
+ onRampTokenAmountWei,
392
+ onRampTokenRaw.decimals,
393
+ );
394
+
395
+ // Build info objects
396
+ const onRampTokenObject = {
397
+ amount: onRampTokenAmount,
398
+ amountWei: onRampTokenAmountWei.toString(),
399
+ amountUSDCents: Math.round(
400
+ Number(onRampTokenAmount) * onRampTokenRaw.priceUsd * 100,
401
+ ),
402
+ token: tokenToPayTokenInfo(onRampTokenRaw),
403
+ };
404
+
405
+ let routingTokenObject:
406
+ | {
407
+ amount: string;
408
+ amountWei: string;
409
+ amountUSDCents: number;
410
+ token: PayTokenInfo;
411
+ }
412
+ | undefined;
413
+
414
+ if (routingTokenRaw) {
415
+ const routingAmountWei = (
416
+ prepared.steps[1] as (typeof prepared.steps)[number]
417
+ ).originAmount;
418
+ const routingAmount = toTokens(
419
+ routingAmountWei,
420
+ routingTokenRaw.decimals,
421
+ );
422
+ routingTokenObject = {
423
+ amount: routingAmount,
424
+ amountWei: routingAmountWei.toString(),
425
+ amountUSDCents: Math.round(
426
+ Number(routingAmount) * routingTokenRaw.priceUsd * 100,
427
+ ),
428
+ token: tokenToPayTokenInfo(routingTokenRaw),
429
+ };
309
430
  }
310
431
 
311
- return (await response.json()).result;
432
+ const buyWithFiatQuote: BuyWithFiatQuote = {
433
+ estimatedDurationSeconds,
434
+ estimatedToAmountMin: estimatedToAmountMin,
435
+ estimatedToAmountMinWei: estimatedToAmountMinWeiBigInt.toString(),
436
+ toAmountMinWei: toAmountMinWeiBigInt.toString(),
437
+ toAmountMin: toAmountMin,
438
+ fromCurrency: {
439
+ amount: prepared.currencyAmount.toString(),
440
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
441
+ decimals: 2,
442
+ currencySymbol: prepared.currency,
443
+ },
444
+ fromCurrencyWithFees: {
445
+ amount: prepared.currencyAmount.toString(),
446
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
447
+ decimals: 2,
448
+ currencySymbol: prepared.currency,
449
+ },
450
+ toToken: tokenToPayTokenInfo(toTokenRaw),
451
+ toAddress: params.toAddress,
452
+ fromAddress: params.fromAddress,
453
+ maxSlippageBPS: maxSlippageBPS,
454
+ intentId: prepared.id,
455
+ processingFees: [],
456
+ onRampToken: onRampTokenObject,
457
+ routingToken: routingTokenObject,
458
+ onRampLink: prepared.link,
459
+ provider: (params.preferredProvider ?? "COINBASE") as FiatProvider,
460
+ };
461
+
462
+ return buyWithFiatQuote;
312
463
  } catch (error) {
313
464
  console.error("Error getting buy with fiat quote", error);
314
465
  throw error;