thirdweb 5.99.3 → 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 (348) hide show
  1. package/dist/cjs/bridge/Buy.js +17 -13
  2. package/dist/cjs/bridge/Buy.js.map +1 -1
  3. package/dist/cjs/bridge/Chains.js +2 -2
  4. package/dist/cjs/bridge/Chains.js.map +1 -1
  5. package/dist/cjs/bridge/Onramp.js +152 -0
  6. package/dist/cjs/bridge/Onramp.js.map +1 -0
  7. package/dist/cjs/bridge/OnrampStatus.js +78 -0
  8. package/dist/cjs/bridge/OnrampStatus.js.map +1 -0
  9. package/dist/cjs/bridge/Routes.js +2 -2
  10. package/dist/cjs/bridge/Routes.js.map +1 -1
  11. package/dist/cjs/bridge/Sell.js +18 -14
  12. package/dist/cjs/bridge/Sell.js.map +1 -1
  13. package/dist/cjs/bridge/Status.js +15 -2
  14. package/dist/cjs/bridge/Status.js.map +1 -1
  15. package/dist/cjs/bridge/Transfer.js +229 -0
  16. package/dist/cjs/bridge/Transfer.js.map +1 -0
  17. package/dist/cjs/bridge/index.js +3 -1
  18. package/dist/cjs/bridge/index.js.map +1 -1
  19. package/dist/cjs/bridge/types/BridgeAction.js +3 -0
  20. package/dist/cjs/bridge/types/BridgeAction.js.map +1 -0
  21. package/dist/cjs/bridge/types/Token.js +3 -0
  22. package/dist/cjs/bridge/types/Token.js.map +1 -0
  23. package/dist/cjs/extensions/ens/resolve-l2-name.js +0 -2
  24. package/dist/cjs/extensions/ens/resolve-l2-name.js.map +1 -1
  25. package/dist/cjs/pay/buyWithCrypto/getQuote.js +159 -53
  26. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  27. package/dist/cjs/pay/buyWithCrypto/getStatus.js +160 -14
  28. package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
  29. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -37
  30. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
  31. package/dist/cjs/pay/buyWithFiat/getQuote.js +129 -33
  32. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  33. package/dist/cjs/pay/buyWithFiat/getStatus.js +71 -20
  34. package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
  35. package/dist/cjs/pay/utils/commonTypes.js +1 -1
  36. package/dist/cjs/pay/utils/commonTypes.js.map +1 -1
  37. package/dist/cjs/pay/utils/definitions.js +1 -43
  38. package/dist/cjs/pay/utils/definitions.js.map +1 -1
  39. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  40. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  41. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +44 -38
  42. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  43. package/dist/cjs/react/core/utils/wallet.js +15 -0
  44. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  45. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
  46. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  47. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -23
  48. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  49. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js +1 -1
  50. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  51. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  52. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  53. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +0 -177
  54. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  55. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  56. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  57. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  58. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  59. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -15
  60. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  61. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -60
  62. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  63. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  64. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  65. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  66. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  67. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +4 -4
  68. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  69. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +83 -34
  70. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  71. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +133 -0
  72. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  73. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  74. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  75. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  76. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  77. package/dist/cjs/utils/any-evm/zksync/constants.js +1 -0
  78. package/dist/cjs/utils/any-evm/zksync/constants.js.map +1 -1
  79. package/dist/cjs/utils/domains.js +3 -0
  80. package/dist/cjs/utils/domains.js.map +1 -1
  81. package/dist/cjs/version.js +1 -1
  82. package/dist/cjs/version.js.map +1 -1
  83. package/dist/esm/bridge/Buy.js +17 -13
  84. package/dist/esm/bridge/Buy.js.map +1 -1
  85. package/dist/esm/bridge/Chains.js +2 -2
  86. package/dist/esm/bridge/Chains.js.map +1 -1
  87. package/dist/esm/bridge/Onramp.js +147 -0
  88. package/dist/esm/bridge/Onramp.js.map +1 -0
  89. package/dist/esm/bridge/OnrampStatus.js +75 -0
  90. package/dist/esm/bridge/OnrampStatus.js.map +1 -0
  91. package/dist/esm/bridge/Routes.js +2 -2
  92. package/dist/esm/bridge/Routes.js.map +1 -1
  93. package/dist/esm/bridge/Sell.js +18 -14
  94. package/dist/esm/bridge/Sell.js.map +1 -1
  95. package/dist/esm/bridge/Status.js +15 -2
  96. package/dist/esm/bridge/Status.js.map +1 -1
  97. package/dist/esm/bridge/Transfer.js +226 -0
  98. package/dist/esm/bridge/Transfer.js.map +1 -0
  99. package/dist/esm/bridge/index.js +2 -0
  100. package/dist/esm/bridge/index.js.map +1 -1
  101. package/dist/esm/bridge/types/BridgeAction.js +2 -0
  102. package/dist/esm/bridge/types/BridgeAction.js.map +1 -0
  103. package/dist/esm/bridge/types/Token.js +2 -0
  104. package/dist/esm/bridge/types/Token.js.map +1 -0
  105. package/dist/esm/extensions/ens/resolve-l2-name.js +0 -2
  106. package/dist/esm/extensions/ens/resolve-l2-name.js.map +1 -1
  107. package/dist/esm/pay/buyWithCrypto/getQuote.js +159 -53
  108. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  109. package/dist/esm/pay/buyWithCrypto/getStatus.js +160 -14
  110. package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
  111. package/dist/esm/pay/buyWithCrypto/getTransfer.js +95 -37
  112. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
  113. package/dist/esm/pay/buyWithFiat/getQuote.js +129 -33
  114. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  115. package/dist/esm/pay/buyWithFiat/getStatus.js +71 -20
  116. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  117. package/dist/esm/pay/utils/commonTypes.js +1 -1
  118. package/dist/esm/pay/utils/commonTypes.js.map +1 -1
  119. package/dist/esm/pay/utils/definitions.js +0 -35
  120. package/dist/esm/pay/utils/definitions.js.map +1 -1
  121. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  122. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  123. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +44 -38
  124. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  125. package/dist/esm/react/core/utils/wallet.js +15 -0
  126. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  127. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
  128. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  129. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -23
  130. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  131. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js +1 -1
  132. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  133. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  134. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  135. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +4 -180
  136. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  137. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  138. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  139. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  140. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  141. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +2 -16
  142. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  143. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -59
  144. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  145. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  146. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  147. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  148. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  149. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +1 -1
  150. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  151. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +84 -34
  152. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  153. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +130 -0
  154. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  155. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  156. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  157. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  158. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  159. package/dist/esm/utils/any-evm/zksync/constants.js +1 -0
  160. package/dist/esm/utils/any-evm/zksync/constants.js.map +1 -1
  161. package/dist/esm/utils/domains.js +3 -0
  162. package/dist/esm/utils/domains.js.map +1 -1
  163. package/dist/esm/version.js +1 -1
  164. package/dist/esm/version.js.map +1 -1
  165. package/dist/types/bridge/Buy.d.ts +11 -9
  166. package/dist/types/bridge/Buy.d.ts.map +1 -1
  167. package/dist/types/bridge/Onramp.d.ts +123 -0
  168. package/dist/types/bridge/Onramp.d.ts.map +1 -0
  169. package/dist/types/bridge/OnrampStatus.d.ts +108 -0
  170. package/dist/types/bridge/OnrampStatus.d.ts.map +1 -0
  171. package/dist/types/bridge/Sell.d.ts +13 -11
  172. package/dist/types/bridge/Sell.d.ts.map +1 -1
  173. package/dist/types/bridge/Status.d.ts.map +1 -1
  174. package/dist/types/bridge/Transfer.d.ts +199 -0
  175. package/dist/types/bridge/Transfer.d.ts.map +1 -0
  176. package/dist/types/bridge/index.d.ts +7 -3
  177. package/dist/types/bridge/index.d.ts.map +1 -1
  178. package/dist/types/bridge/types/BridgeAction.d.ts +2 -0
  179. package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -0
  180. package/dist/types/bridge/types/Quote.d.ts +3 -65
  181. package/dist/types/bridge/types/Quote.d.ts.map +1 -1
  182. package/dist/types/bridge/types/Route.d.ts +38 -17
  183. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  184. package/dist/types/bridge/types/Status.d.ts +15 -0
  185. package/dist/types/bridge/types/Status.d.ts.map +1 -1
  186. package/dist/types/bridge/types/Token.d.ts +11 -0
  187. package/dist/types/bridge/types/Token.d.ts.map +1 -0
  188. package/dist/types/extensions/ens/resolve-l2-name.d.ts.map +1 -1
  189. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +0 -9
  190. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -1
  191. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  192. package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
  193. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  194. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
  195. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  196. package/dist/types/pay/buyWithFiat/getStatus.d.ts +1 -12
  197. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  198. package/dist/types/pay/utils/commonTypes.d.ts +1 -1
  199. package/dist/types/pay/utils/commonTypes.d.ts.map +1 -1
  200. package/dist/types/pay/utils/definitions.d.ts +0 -35
  201. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  202. package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts.map +1 -1
  203. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +1 -0
  204. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  205. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  206. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  207. package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
  208. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts +1 -30
  209. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts.map +1 -1
  210. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +2 -0
  211. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  212. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +2 -0
  213. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
  214. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts +0 -5
  215. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
  216. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts +1 -3
  217. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts.map +1 -1
  218. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
  219. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts +0 -1
  220. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts.map +1 -1
  221. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +8 -4
  222. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
  223. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +15 -0
  224. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -0
  225. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
  226. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +1 -0
  227. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
  228. package/dist/types/utils/any-evm/zksync/constants.d.ts.map +1 -1
  229. package/dist/types/utils/domains.d.ts +6 -0
  230. package/dist/types/utils/domains.d.ts.map +1 -1
  231. package/dist/types/version.d.ts +1 -1
  232. package/dist/types/version.d.ts.map +1 -1
  233. package/package.json +15 -15
  234. package/src/bridge/Buy.ts +19 -13
  235. package/src/bridge/Chains.ts +2 -2
  236. package/src/bridge/Onramp.test.ts +118 -0
  237. package/src/bridge/Onramp.ts +244 -0
  238. package/src/bridge/OnrampStatus.ts +133 -0
  239. package/src/bridge/Routes.ts +2 -2
  240. package/src/bridge/Sell.ts +20 -14
  241. package/src/bridge/Status.ts +15 -2
  242. package/src/bridge/Transfer.test.ts +76 -0
  243. package/src/bridge/Transfer.ts +270 -0
  244. package/src/bridge/index.ts +12 -3
  245. package/src/bridge/types/BridgeAction.ts +1 -0
  246. package/src/bridge/types/Quote.ts +3 -65
  247. package/src/bridge/types/Route.ts +42 -17
  248. package/src/bridge/types/Status.ts +15 -1
  249. package/src/bridge/types/Token.ts +11 -0
  250. package/src/extensions/ens/resolve-l2-name.ts +0 -2
  251. package/src/pay/buyWithCrypto/commonTypes.ts +0 -10
  252. package/src/pay/buyWithCrypto/getQuote.ts +210 -100
  253. package/src/pay/buyWithCrypto/getStatus.ts +213 -20
  254. package/src/pay/buyWithCrypto/getTransfer.ts +129 -61
  255. package/src/pay/buyWithFiat/getQuote.ts +184 -33
  256. package/src/pay/buyWithFiat/getStatus.ts +101 -42
  257. package/src/pay/convert/cryptoToFiat.test.ts +7 -5
  258. package/src/pay/convert/fiatToCrypto.test.ts +6 -4
  259. package/src/pay/utils/commonTypes.ts +1 -1
  260. package/src/pay/utils/definitions.ts +0 -48
  261. package/src/react/core/hooks/pay/useBuyWithFiatStatus.ts +0 -2
  262. package/src/react/core/hooks/transaction/useSendTransaction.ts +53 -52
  263. package/src/react/core/utils/wallet.ts +15 -0
  264. package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
  265. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +5 -64
  266. package/src/react/web/ui/ConnectWallet/locale/en.ts +1 -1
  267. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
  268. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +3 -510
  269. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +2 -12
  270. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +2 -0
  271. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +19 -20
  272. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -37
  273. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts +1 -95
  274. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts +0 -69
  275. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +3 -1
  276. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +1 -1
  277. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.ts +1 -3
  278. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +118 -63
  279. package/src/react/web/ui/TransactionButton/DepositScreen.tsx +295 -0
  280. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +4 -5
  281. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +20 -1
  282. package/src/utils/any-evm/zksync/constants.ts +1 -0
  283. package/src/utils/domain.test.ts +1 -0
  284. package/src/utils/domains.ts +8 -0
  285. package/src/version.ts +1 -1
  286. package/dist/cjs/bridge/constants.js +0 -5
  287. package/dist/cjs/bridge/constants.js.map +0 -1
  288. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -37
  289. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  290. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -86
  291. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  292. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -25
  293. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  294. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -54
  295. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  296. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -52
  297. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  298. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -81
  299. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  300. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -17
  301. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  302. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -138
  303. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  304. package/dist/esm/bridge/constants.js +0 -2
  305. package/dist/esm/bridge/constants.js.map +0 -1
  306. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -34
  307. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  308. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -83
  309. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  310. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -22
  311. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  312. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -51
  313. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  314. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -48
  315. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  316. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -78
  317. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  318. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -14
  319. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  320. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -135
  321. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  322. package/dist/types/bridge/constants.d.ts +0 -2
  323. package/dist/types/bridge/constants.d.ts.map +0 -1
  324. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts +0 -26
  325. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts.map +0 -1
  326. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +0 -16
  327. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +0 -1
  328. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +0 -23
  329. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +0 -1
  330. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +0 -10
  331. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +0 -1
  332. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts +0 -9
  333. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts.map +0 -1
  334. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +0 -14
  335. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +0 -1
  336. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +0 -14
  337. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +0 -1
  338. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +0 -21
  339. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +0 -1
  340. package/src/bridge/constants.ts +0 -1
  341. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +0 -142
  342. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +0 -170
  343. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +0 -63
  344. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +0 -163
  345. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.tsx +0 -127
  346. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +0 -138
  347. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +0 -45
  348. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +0 -191
@@ -1,17 +1,13 @@
1
- import type { Hash } from "viem";
1
+ import { Value } from "ox";
2
+ import * as ox__AbiFunction from "ox/AbiFunction";
3
+ import { Transfer } from "../../bridge/index.js";
2
4
  import { getCachedChain } from "../../chains/utils.js";
3
5
  import type { ThirdwebClient } from "../../client/client.js";
6
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
7
+ import { getContract } from "../../contract/contract.js";
8
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
4
9
  import type { PrepareTransactionOptions } from "../../transaction/prepare-transaction.js";
5
- import type { Address } from "../../utils/address.js";
6
- import { getClientFetch } from "../../utils/fetch.js";
7
- import { stringify } from "../../utils/json.js";
8
- import { getPayBuyWithCryptoTransferEndpoint } from "../utils/definitions.js";
9
- import type {
10
- QuoteApprovalInfo,
11
- QuotePaymentToken,
12
- QuoteTokenInfo,
13
- QuoteTransactionRequest,
14
- } from "./commonTypes.js";
10
+ import type { QuoteApprovalInfo, QuotePaymentToken } from "./commonTypes.js";
15
11
 
16
12
  /**
17
13
  * The parameters for [`getBuyWithCryptoTransfer`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithCryptoTransfer) function
@@ -66,21 +62,6 @@ export type GetBuyWithCryptoTransferParams = {
66
62
  feePayer?: "sender" | "receiver";
67
63
  };
68
64
 
69
- /**
70
- * @buyCrypto
71
- */
72
- type BuyWithCryptoTransferResponse = {
73
- quoteId: string;
74
- transactionRequest: QuoteTransactionRequest;
75
- approval?: QuoteApprovalInfo;
76
- fromAddress: string;
77
- toAddress: string;
78
- token: QuoteTokenInfo;
79
- paymentToken: QuotePaymentToken;
80
- processingFee: QuotePaymentToken;
81
- estimatedGasCostUSDCents: number;
82
- };
83
-
84
65
  /**
85
66
  * @buyCrypto
86
67
  */
@@ -126,50 +107,137 @@ export async function getBuyWithCryptoTransfer(
126
107
  params: GetBuyWithCryptoTransferParams,
127
108
  ): Promise<BuyWithCryptoTransfer> {
128
109
  try {
129
- const clientFetch = getClientFetch(params.client);
130
-
131
- const response = await clientFetch(getPayBuyWithCryptoTransferEndpoint(), {
132
- method: "POST",
133
- headers: {
134
- Accept: "application/json",
135
- "Content-Type": "application/json",
136
- },
137
- body: stringify({
138
- fromAddress: params.fromAddress,
139
- toAddress: params.toAddress,
140
- chainId: params.chainId,
141
- tokenAddress: params.tokenAddress,
142
- amount: params.amount,
143
- purchaseData: params.purchaseData,
144
- feePayer: params.feePayer,
145
- }),
110
+ const tokenContract = getContract({
111
+ address: params.tokenAddress,
112
+ chain: getCachedChain(params.chainId),
113
+ client: params.client,
114
+ });
115
+ const tokenDecimals =
116
+ tokenContract.address.toLowerCase() === NATIVE_TOKEN_ADDRESS
117
+ ? 18
118
+ : await decimals({
119
+ contract: tokenContract,
120
+ });
121
+ const amount = Value.from(params.amount, tokenDecimals);
122
+ const quote = await Transfer.prepare({
123
+ chainId: params.chainId,
124
+ tokenAddress: params.tokenAddress,
125
+ amount,
126
+ sender: params.fromAddress,
127
+ receiver: params.toAddress,
128
+ client: params.client,
129
+ feePayer: params.feePayer,
146
130
  });
147
131
 
148
- if (!response.ok) {
149
- const errorObj = await response.json();
150
- if (errorObj && "error" in errorObj) {
151
- throw errorObj;
152
- }
153
- throw new Error(`HTTP error! status: ${response.status}`);
132
+ const firstStep = quote.steps[0];
133
+ if (!firstStep) {
134
+ throw new Error(
135
+ "This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.",
136
+ );
154
137
  }
155
138
 
156
- const data: BuyWithCryptoTransferResponse = (await response.json()).result;
139
+ const approvalTxs = firstStep.transactions.filter(
140
+ (tx) => tx.action === "approval",
141
+ );
142
+ if (approvalTxs.length > 1) {
143
+ throw new Error(
144
+ "This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.",
145
+ );
146
+ }
147
+ const approvalTx = approvalTxs[0];
148
+
149
+ let approvalData: QuoteApprovalInfo | undefined;
150
+ if (approvalTx) {
151
+ const abiFunction = ox__AbiFunction.from([
152
+ "function approve(address spender, uint256 amount)",
153
+ ]);
154
+ const [spender, amount] = ox__AbiFunction.decodeData(
155
+ abiFunction,
156
+ approvalTx.data,
157
+ );
158
+ approvalData = {
159
+ chainId: firstStep.originToken.chainId,
160
+ tokenAddress: firstStep.originToken.address,
161
+ spenderAddress: spender,
162
+ amountWei: amount.toString(),
163
+ };
164
+ }
165
+
166
+ const txs = firstStep.transactions.filter((tx) => tx.action !== "approval");
167
+ if (txs.length > 1) {
168
+ throw new Error(
169
+ "This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.",
170
+ );
171
+ }
172
+ const tx = txs[0];
173
+ if (!tx) {
174
+ throw new Error(
175
+ "This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.",
176
+ );
177
+ }
157
178
 
158
179
  const transfer: BuyWithCryptoTransfer = {
159
180
  transactionRequest: {
160
- chain: getCachedChain(data.transactionRequest.chainId),
161
- client: params.client,
162
- data: data.transactionRequest.data as Hash,
163
- to: data.transactionRequest.to as Address,
164
- value: BigInt(data.transactionRequest.value),
181
+ ...tx,
165
182
  extraGas: 50000n, // extra gas buffer
166
183
  },
167
- approvalData: data.approval,
168
- fromAddress: data.fromAddress,
169
- toAddress: data.toAddress,
170
- paymentToken: data.paymentToken,
171
- processingFee: data.processingFee,
172
- estimatedGasCostUSDCents: data.estimatedGasCostUSDCents,
184
+ approvalData,
185
+ fromAddress: params.fromAddress,
186
+ toAddress: params.toAddress,
187
+ paymentToken: {
188
+ token: {
189
+ tokenAddress: firstStep.originToken.address,
190
+ chainId: firstStep.originToken.chainId,
191
+ decimals: firstStep.originToken.decimals,
192
+ symbol: firstStep.originToken.symbol,
193
+ name: firstStep.originToken.name,
194
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
195
+ },
196
+ amountWei: quote.originAmount.toString(),
197
+ amount: Value.format(
198
+ quote.originAmount,
199
+ firstStep.originToken.decimals,
200
+ ).toString(),
201
+ amountUSDCents:
202
+ Number(
203
+ Value.format(quote.originAmount, firstStep.originToken.decimals),
204
+ ) *
205
+ firstStep.originToken.priceUsd *
206
+ 100,
207
+ },
208
+ processingFee: {
209
+ token: {
210
+ tokenAddress: firstStep.originToken.address,
211
+ chainId: firstStep.originToken.chainId,
212
+ decimals: firstStep.originToken.decimals,
213
+ symbol: firstStep.originToken.symbol,
214
+ name: firstStep.originToken.name,
215
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
216
+ },
217
+ amountWei:
218
+ params.feePayer === "sender"
219
+ ? (quote.originAmount - quote.destinationAmount).toString()
220
+ : "0",
221
+ amount:
222
+ params.feePayer === "sender"
223
+ ? Value.format(
224
+ quote.originAmount - quote.destinationAmount,
225
+ firstStep.originToken.decimals,
226
+ ).toString()
227
+ : "0",
228
+ amountUSDCents:
229
+ params.feePayer === "sender"
230
+ ? Number(
231
+ Value.format(
232
+ quote.originAmount - quote.destinationAmount,
233
+ firstStep.originToken.decimals,
234
+ ),
235
+ ) *
236
+ firstStep.originToken.priceUsd *
237
+ 100
238
+ : 0,
239
+ },
240
+ estimatedGasCostUSDCents: 0,
173
241
  client: params.client,
174
242
  };
175
243
 
@@ -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;
@@ -1,10 +1,9 @@
1
+ import { status as onrampStatus } from "../../bridge/OnrampStatus.js";
1
2
  import type { ThirdwebClient } from "../../client/client.js";
2
- import { getClientFetch } from "../../utils/fetch.js";
3
3
  import type {
4
4
  PayOnChainTransactionDetails,
5
5
  PayTokenInfo,
6
6
  } from "../utils/commonTypes.js";
7
- import { getPayBuyWithFiatStatusEndpoint } from "../utils/definitions.js";
8
7
 
9
8
  /**
10
9
  * Parameters for the [`getBuyWithFiatStatus`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatStatus) function
@@ -25,11 +24,6 @@ export type GetBuyWithFiatStatusParams = {
25
24
  intentId: string;
26
25
  };
27
26
 
28
- export type ValidBuyWithFiatStatus = Exclude<
29
- BuyWithFiatStatus,
30
- { status: "NOT_FOUND" }
31
- >;
32
-
33
27
  /**
34
28
  * The returned object from [`getBuyWithFiatStatus`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatStatus) function
35
29
  *
@@ -50,28 +44,13 @@ export type BuyWithFiatStatus =
50
44
  * - `NONE` - No status
51
45
  * - `PENDING_PAYMENT` - Payment is not done yet in the on-ramp provider
52
46
  * - `PAYMENT_FAILED` - Payment failed in the on-ramp provider
53
- * - `PENDING_ON_RAMP_TRANSFER` - Payment is done but the on-ramp provider is yet to transfer the tokens to the user's wallet
54
- * - `ON_RAMP_TRANSFER_IN_PROGRESS` - On-ramp provider is transferring the tokens to the user's wallet
55
47
  * - `ON_RAMP_TRANSFER_COMPLETED` - On-ramp provider has transferred the tokens to the user's wallet
56
- * - `ON_RAMP_TRANSFER_FAILED` - On-ramp provider failed to transfer the tokens to the user's wallet
57
- * - `CRYPTO_SWAP_REQUIRED` - On-ramp provider has sent the tokens to the user's wallet but a swap is required to convert it to the desired token
58
- * - `CRYPTO_SWAP_IN_PROGRESS` - Swap is in progress
59
- * - `CRYPTO_SWAP_COMPLETED` - Swap is completed and the user has received the desired token
60
- * - `CRYPTO_SWAP_FALLBACK` - Swap failed and the user has received a fallback token which is not the desired token
61
48
  */
62
49
  status:
63
50
  | "NONE"
64
51
  | "PENDING_PAYMENT"
65
52
  | "PAYMENT_FAILED"
66
- | "PENDING_ON_RAMP_TRANSFER"
67
- | "ON_RAMP_TRANSFER_IN_PROGRESS"
68
- | "ON_RAMP_TRANSFER_COMPLETED"
69
- | "ON_RAMP_TRANSFER_FAILED"
70
- | "CRYPTO_SWAP_REQUIRED"
71
- | "CRYPTO_SWAP_COMPLETED"
72
- | "CRYPTO_SWAP_FALLBACK"
73
- | "CRYPTO_SWAP_IN_PROGRESS"
74
- | "CRYPTO_SWAP_FAILED";
53
+ | "ON_RAMP_TRANSFER_COMPLETED";
75
54
  /**
76
55
  * The wallet address to which the desired tokens are sent to
77
56
  */
@@ -171,7 +150,6 @@ export type BuyWithFiatStatus =
171
150
  * })
172
151
  *
173
152
  * // when the fiatStatus.status is "ON_RAMP_TRANSFER_COMPLETED" - the process is complete
174
- * // when the fiatStatus.status is "CRYPTO_SWAP_REQUIRED" - start the swap process
175
153
  * ```
176
154
  * @deprecated
177
155
  * @buyCrypto
@@ -179,26 +157,107 @@ export type BuyWithFiatStatus =
179
157
  export async function getBuyWithFiatStatus(
180
158
  params: GetBuyWithFiatStatusParams,
181
159
  ): Promise<BuyWithFiatStatus> {
182
- try {
183
- const queryParams = new URLSearchParams({
184
- intentId: params.intentId,
185
- });
160
+ const result = await onrampStatus({
161
+ id: params.intentId,
162
+ client: params.client,
163
+ });
186
164
 
187
- const queryString = queryParams.toString();
188
- const url = `${getPayBuyWithFiatStatusEndpoint()}?${queryString}`;
165
+ return toBuyWithFiatStatus({ intentId: params.intentId, result });
166
+ }
189
167
 
190
- const response = await getClientFetch(params.client)(url);
168
+ ////////////////////////////////////////////////////////////////////////////////
169
+ // Helpers
170
+ ////////////////////////////////////////////////////////////////////////////////
191
171
 
192
- if (!response.ok) {
193
- const error = await response.text().catch(() => null);
194
- throw new Error(
195
- `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
196
- );
197
- }
172
+ function toBuyWithFiatStatus(args: {
173
+ intentId: string;
174
+ result: Awaited<ReturnType<typeof onrampStatus>>;
175
+ }): BuyWithFiatStatus {
176
+ const { intentId, result } = args;
177
+
178
+ // Map status constants from the Bridge.Onramp.status response to BuyWithFiatStatus equivalents.
179
+ const STATUS_MAP: Record<
180
+ typeof result.status,
181
+ "NONE" | "PENDING_PAYMENT" | "PAYMENT_FAILED" | "ON_RAMP_TRANSFER_COMPLETED"
182
+ > = {
183
+ CREATED: "PENDING_PAYMENT",
184
+ PENDING: "PENDING_PAYMENT",
185
+ FAILED: "PAYMENT_FAILED",
186
+ COMPLETED: "ON_RAMP_TRANSFER_COMPLETED",
187
+ } as const;
188
+
189
+ const mappedStatus = STATUS_MAP[result.status];
190
+
191
+ return buildPlaceholderStatus({
192
+ intentId,
193
+ status: mappedStatus,
194
+ purchaseData: result.purchaseData,
195
+ });
196
+ }
197
+
198
+ function buildPlaceholderStatus(args: {
199
+ intentId: string;
200
+ status:
201
+ | "NONE"
202
+ | "PENDING_PAYMENT"
203
+ | "PAYMENT_FAILED"
204
+ | "ON_RAMP_TRANSFER_COMPLETED";
205
+ purchaseData?: unknown;
206
+ }): BuyWithFiatStatus {
207
+ const { intentId, status, purchaseData } = args;
208
+
209
+ // Build a minimal—but type-complete—object that satisfies BuyWithFiatStatus.
210
+ const emptyToken: PayTokenInfo = {
211
+ chainId: 0,
212
+ tokenAddress: "",
213
+ decimals: 18,
214
+ priceUSDCents: 0,
215
+ name: "",
216
+ symbol: "",
217
+ };
218
+
219
+ type BuyWithFiatStatusWithData = Exclude<
220
+ BuyWithFiatStatus,
221
+ { status: "NOT_FOUND" }
222
+ >;
223
+
224
+ const quote: BuyWithFiatStatusWithData["quote"] = {
225
+ estimatedOnRampAmount: "0",
226
+ estimatedOnRampAmountWei: "0",
227
+
228
+ estimatedToTokenAmount: "0",
229
+ estimatedToTokenAmountWei: "0",
230
+
231
+ fromCurrency: {
232
+ amount: "0",
233
+ amountUnits: "USD",
234
+ decimals: 2,
235
+ currencySymbol: "USD",
236
+ },
237
+ fromCurrencyWithFees: {
238
+ amount: "0",
239
+ amountUnits: "USD",
240
+ decimals: 2,
241
+ currencySymbol: "USD",
242
+ },
243
+ onRampToken: emptyToken,
244
+ toToken: emptyToken,
245
+ estimatedDurationSeconds: 0,
246
+ createdAt: new Date().toISOString(),
247
+ } as BuyWithFiatStatusWithData["quote"];
248
+
249
+ // The source/destination fields can only be filled accurately when extra context is returned
250
+ // by the API. Since Bridge.Onramp.status doesn't yet provide these details, we omit them for
251
+ // now (they are optional).
252
+
253
+ const base: Exclude<BuyWithFiatStatus, { status: "NOT_FOUND" }> = {
254
+ intentId,
255
+ status,
256
+ toAddress: "",
257
+ fromAddress: "",
258
+ quote,
259
+ purchaseData: purchaseData as object | undefined,
260
+ };
198
261
 
199
- return (await response.json()).result;
200
- } catch (error) {
201
- console.error("Fetch error:", error);
202
- throw new Error(`Fetch failed: ${error}`);
203
- }
262
+ return base;
204
263
  }
@@ -1,10 +1,12 @@
1
1
  import { describe, expect, it, vi } from "vitest";
2
2
  import { TEST_CLIENT } from "~test/test-clients.js";
3
- import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
4
3
  import { base } from "../../chains/chain-definitions/base.js";
5
4
  import { ethereum } from "../../chains/chain-definitions/ethereum.js";
6
5
  import { sepolia } from "../../chains/chain-definitions/sepolia.js";
7
- import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
6
+ import {
7
+ NATIVE_TOKEN_ADDRESS,
8
+ ZERO_ADDRESS,
9
+ } from "../../constants/addresses.js";
8
10
  import { convertCryptoToFiat } from "./cryptoToFiat.js";
9
11
 
10
12
  describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
@@ -49,7 +51,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
49
51
  expect(data.result).toBe(0);
50
52
  });
51
53
 
52
- it("should throw error for testnet chain (because testnets are not supported", async () => {
54
+ it("should throw error for testnet chain (because testnets are not supported)", async () => {
53
55
  await expect(
54
56
  convertCryptoToFiat({
55
57
  chain: sepolia,
@@ -81,13 +83,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("Pay: crypto-to-fiat", () => {
81
83
  await expect(
82
84
  convertCryptoToFiat({
83
85
  chain: base,
84
- fromTokenAddress: TEST_ACCOUNT_A.address,
86
+ fromTokenAddress: ZERO_ADDRESS,
85
87
  fromAmount: 1,
86
88
  to: "USD",
87
89
  client: TEST_CLIENT,
88
90
  }),
89
91
  ).rejects.toThrowError(
90
- `Error: ${TEST_ACCOUNT_A.address} on chainId: ${base.id} is not a valid contract address.`,
92
+ `Error: ${ZERO_ADDRESS} on chainId: ${base.id} is not a valid contract address.`,
91
93
  );
92
94
  });
93
95
  it("should throw if response is not OK", async () => {