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,5 +1,5 @@
1
- import { getClientFetch } from "../../utils/fetch.js";
2
- import { getPayBuyWithCryptoStatusUrl } from "../utils/definitions.js";
1
+ import { status as bridgeStatus } from "../../bridge/index.js";
2
+ import { toTokens } from "../../utils/units.js";
3
3
  /**
4
4
  * Gets the status of a buy with crypto transaction
5
5
  * @param buyWithCryptoTransaction - Object of type [`BuyWithCryptoTransaction`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoTransaction)
@@ -37,7 +37,7 @@ import { getPayBuyWithCryptoStatusUrl } from "../utils/definitions.js";
37
37
  * }});
38
38
  * ```
39
39
  * @returns Object of type [`BuyWithCryptoStatus`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoStatus)
40
- * @deprecated
40
+ * @deprecated use Bridge.status instead
41
41
  * @buyCrypto
42
42
  */
43
43
  export async function getBuyWithCryptoStatus(buyWithCryptoTransaction) {
@@ -45,23 +45,169 @@ export async function getBuyWithCryptoStatus(buyWithCryptoTransaction) {
45
45
  if (!buyWithCryptoTransaction.transactionHash) {
46
46
  throw new Error("Transaction hash is required");
47
47
  }
48
- const queryString = new URLSearchParams({
48
+ const result = await bridgeStatus({
49
49
  transactionHash: buyWithCryptoTransaction.transactionHash,
50
- chainId: buyWithCryptoTransaction.chainId.toString(),
51
- }).toString();
52
- const url = `${getPayBuyWithCryptoStatusUrl()}?${queryString}`;
53
- const response = await getClientFetch(buyWithCryptoTransaction.client)(url);
54
- // Assuming the response directly matches the BuyWithCryptoStatus interface
55
- if (!response.ok) {
56
- const error = await response.text().catch(() => null);
57
- throw new Error(`HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`);
50
+ chainId: buyWithCryptoTransaction.chainId,
51
+ client: buyWithCryptoTransaction.client,
52
+ });
53
+ switch (result.status) {
54
+ case "COMPLETED": {
55
+ const originTransaction = result.transactions?.find((tx) => tx.chainId === buyWithCryptoTransaction.chainId);
56
+ const destinationTransaction = result.transactions?.find((tx) => tx.chainId !== buyWithCryptoTransaction.chainId);
57
+ return toBuyWithCryptoStatus({
58
+ originTransaction,
59
+ destinationTransaction,
60
+ originAmount: result.originAmount,
61
+ destinationAmount: result.destinationAmount,
62
+ originTokenAddress: result.originTokenAddress,
63
+ destinationTokenAddress: result.destinationTokenAddress,
64
+ originChainId: result.originChainId,
65
+ destinationChainId: result.destinationChainId,
66
+ status: result.status,
67
+ sender: result.sender,
68
+ receiver: result.receiver,
69
+ paymentId: result.paymentId,
70
+ originToken: result.originToken,
71
+ destinationToken: result.destinationToken,
72
+ purchaseData: result.purchaseData,
73
+ });
74
+ }
75
+ case "PENDING": {
76
+ return toBuyWithCryptoStatus({
77
+ originAmount: result.originAmount,
78
+ originTokenAddress: result.originTokenAddress,
79
+ destinationTokenAddress: result.destinationTokenAddress,
80
+ originChainId: result.originChainId,
81
+ destinationChainId: result.destinationChainId,
82
+ status: result.status,
83
+ sender: result.sender,
84
+ receiver: result.receiver,
85
+ paymentId: result.paymentId,
86
+ originToken: result.originToken,
87
+ destinationToken: result.destinationToken,
88
+ purchaseData: result.purchaseData,
89
+ });
90
+ }
91
+ case "FAILED": {
92
+ const originTransaction = result.transactions?.find((tx) => tx.chainId === buyWithCryptoTransaction.chainId);
93
+ const destinationTransaction = result.transactions?.find((tx) => tx.chainId !== buyWithCryptoTransaction.chainId);
94
+ return toBuyWithCryptoStatus({
95
+ originTransaction,
96
+ destinationTransaction,
97
+ originAmount: BigInt(0), // TODO: get from API
98
+ originTokenAddress: "", // TODO: get from API
99
+ destinationTokenAddress: "", // TODO: get from API
100
+ originChainId: 0, // TODO: get from API
101
+ destinationChainId: 0, // TODO: get from API
102
+ status: result.status,
103
+ sender: "",
104
+ receiver: "",
105
+ paymentId: "",
106
+ originToken: undefined,
107
+ destinationToken: undefined,
108
+ purchaseData: result.purchaseData,
109
+ });
110
+ }
111
+ default: {
112
+ return {
113
+ status: "NOT_FOUND",
114
+ };
115
+ }
58
116
  }
59
- const data = (await response.json()).result;
60
- return data;
61
117
  }
62
118
  catch (error) {
63
119
  console.error("Fetch error:", error);
64
120
  throw new Error(`Fetch failed: ${error}`);
65
121
  }
66
122
  }
123
+ function toBuyWithCryptoStatus(args) {
124
+ const { originTransaction, destinationTransaction, status, purchaseData, originAmount, destinationAmount, originTokenAddress, destinationTokenAddress, originChainId, destinationChainId, sender, receiver, originToken, destinationToken, } = args;
125
+ return {
126
+ fromAddress: sender,
127
+ toAddress: receiver,
128
+ quote: {
129
+ createdAt: new Date().toISOString(),
130
+ estimated: {
131
+ fromAmountUSDCents: 0,
132
+ toAmountMinUSDCents: 0,
133
+ toAmountUSDCents: 0,
134
+ slippageBPS: 0,
135
+ feesUSDCents: 0,
136
+ gasCostUSDCents: 0,
137
+ durationSeconds: 0,
138
+ },
139
+ fromAmount: originToken
140
+ ? toTokens(originAmount, originToken.decimals).toString()
141
+ : "",
142
+ fromAmountWei: originAmount.toString(),
143
+ toAmount: destinationToken && destinationAmount
144
+ ? toTokens(destinationAmount, destinationToken.decimals).toString()
145
+ : "",
146
+ toAmountWei: destinationAmount ? destinationAmount.toString() : "",
147
+ toAmountMin: destinationToken
148
+ ? toTokens(destinationAmount ?? BigInt(0), destinationToken.decimals).toString()
149
+ : "",
150
+ toAmountMinWei: destinationAmount ? destinationAmount.toString() : "",
151
+ fromToken: {
152
+ tokenAddress: originTokenAddress,
153
+ chainId: originChainId,
154
+ decimals: originToken?.decimals ?? 18,
155
+ name: originToken?.name ?? "",
156
+ symbol: originToken?.symbol ?? "",
157
+ priceUSDCents: 0,
158
+ },
159
+ toToken: {
160
+ tokenAddress: destinationTokenAddress,
161
+ chainId: destinationChainId,
162
+ decimals: destinationToken?.decimals ?? 18,
163
+ name: destinationToken?.name ?? "",
164
+ symbol: destinationToken?.symbol ?? "",
165
+ priceUSDCents: 0,
166
+ },
167
+ },
168
+ swapType: originTransaction?.chainId === destinationTransaction?.chainId
169
+ ? "SAME_CHAIN"
170
+ : "CROSS_CHAIN", // TODO transfer type?
171
+ status: status,
172
+ subStatus: status === "COMPLETED" ? "SUCCESS" : "NONE",
173
+ purchaseData: purchaseData,
174
+ bridge: "STARPORT",
175
+ destination: {
176
+ amount: destinationToken
177
+ ? toTokens(destinationAmount ?? BigInt(0), destinationToken.decimals).toString()
178
+ : "",
179
+ amountWei: destinationAmount?.toString() ?? "",
180
+ token: {
181
+ tokenAddress: destinationTokenAddress,
182
+ chainId: destinationChainId,
183
+ decimals: destinationToken?.decimals ?? 18,
184
+ name: destinationToken?.name ?? "",
185
+ symbol: destinationToken?.symbol ?? "",
186
+ priceUSDCents: 0,
187
+ },
188
+ amountUSDCents: 0,
189
+ completedAt: new Date().toISOString(),
190
+ explorerLink: "",
191
+ transactionHash: destinationTransaction?.transactionHash ?? "",
192
+ },
193
+ source: {
194
+ amount: originToken
195
+ ? toTokens(originAmount, originToken.decimals).toString()
196
+ : "",
197
+ amountWei: originAmount.toString(),
198
+ token: {
199
+ tokenAddress: originTokenAddress,
200
+ chainId: originChainId,
201
+ decimals: originToken?.decimals ?? 18,
202
+ name: originToken?.name ?? "",
203
+ symbol: originToken?.symbol ?? "",
204
+ priceUSDCents: 0,
205
+ },
206
+ amountUSDCents: 0,
207
+ completedAt: new Date().toISOString(),
208
+ explorerLink: "",
209
+ transactionHash: originTransaction?.transactionHash ?? "",
210
+ },
211
+ };
212
+ }
67
213
  //# sourceMappingURL=getStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStatus.js","sourceRoot":"","sources":["../../../../src/pay/buyWithCrypto/getStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAkFvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,wBAAkD;IAElD,IAAI,CAAC;QACH,IAAI,CAAC,wBAAwB,CAAC,eAAe,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC;YACtC,eAAe,EAAE,wBAAwB,CAAC,eAAe;YACzD,OAAO,EAAE,wBAAwB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AAE,CAAC;YACjB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,iBAAiB,EAAE,eAAe,IAAI,EAAE;SAC1D;KACF,CAAC;AACJ,CAAC"}
@@ -1,7 +1,10 @@
1
+ import { Value } from "ox";
2
+ import * as ox__AbiFunction from "ox/AbiFunction";
3
+ import { Transfer } from "../../bridge/index.js";
1
4
  import { getCachedChain } from "../../chains/utils.js";
2
- import { getClientFetch } from "../../utils/fetch.js";
3
- import { stringify } from "../../utils/json.js";
4
- import { getPayBuyWithCryptoTransferEndpoint } from "../utils/definitions.js";
5
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
6
+ import { getContract } from "../../contract/contract.js";
7
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
5
8
  /**
6
9
  * Get a quote of type [`BuyWithCryptoTransfer`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoTransfer) to facilitate a token transfer transaction.
7
10
  * Using this instead of a native transfer allows you to receive status and webhooks about successful or failed payments.
@@ -31,46 +34,101 @@ import { getPayBuyWithCryptoTransferEndpoint } from "../utils/definitions.js";
31
34
  */
32
35
  export async function getBuyWithCryptoTransfer(params) {
33
36
  try {
34
- const clientFetch = getClientFetch(params.client);
35
- const response = await clientFetch(getPayBuyWithCryptoTransferEndpoint(), {
36
- method: "POST",
37
- headers: {
38
- Accept: "application/json",
39
- "Content-Type": "application/json",
40
- },
41
- body: stringify({
42
- fromAddress: params.fromAddress,
43
- toAddress: params.toAddress,
44
- chainId: params.chainId,
45
- tokenAddress: params.tokenAddress,
46
- amount: params.amount,
47
- purchaseData: params.purchaseData,
48
- feePayer: params.feePayer,
49
- }),
37
+ const tokenContract = getContract({
38
+ address: params.tokenAddress,
39
+ chain: getCachedChain(params.chainId),
40
+ client: params.client,
50
41
  });
51
- if (!response.ok) {
52
- const errorObj = await response.json();
53
- if (errorObj && "error" in errorObj) {
54
- throw errorObj;
55
- }
56
- throw new Error(`HTTP error! status: ${response.status}`);
42
+ const tokenDecimals = tokenContract.address.toLowerCase() === NATIVE_TOKEN_ADDRESS
43
+ ? 18
44
+ : await decimals({
45
+ contract: tokenContract,
46
+ });
47
+ const amount = Value.from(params.amount, tokenDecimals);
48
+ const quote = await Transfer.prepare({
49
+ chainId: params.chainId,
50
+ tokenAddress: params.tokenAddress,
51
+ amount,
52
+ sender: params.fromAddress,
53
+ receiver: params.toAddress,
54
+ client: params.client,
55
+ feePayer: params.feePayer,
56
+ });
57
+ const firstStep = quote.steps[0];
58
+ if (!firstStep) {
59
+ throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");
60
+ }
61
+ const approvalTxs = firstStep.transactions.filter((tx) => tx.action === "approval");
62
+ if (approvalTxs.length > 1) {
63
+ throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");
64
+ }
65
+ const approvalTx = approvalTxs[0];
66
+ let approvalData;
67
+ if (approvalTx) {
68
+ const abiFunction = ox__AbiFunction.from([
69
+ "function approve(address spender, uint256 amount)",
70
+ ]);
71
+ const [spender, amount] = ox__AbiFunction.decodeData(abiFunction, approvalTx.data);
72
+ approvalData = {
73
+ chainId: firstStep.originToken.chainId,
74
+ tokenAddress: firstStep.originToken.address,
75
+ spenderAddress: spender,
76
+ amountWei: amount.toString(),
77
+ };
78
+ }
79
+ const txs = firstStep.transactions.filter((tx) => tx.action !== "approval");
80
+ if (txs.length > 1) {
81
+ throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");
82
+ }
83
+ const tx = txs[0];
84
+ if (!tx) {
85
+ throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");
57
86
  }
58
- const data = (await response.json()).result;
59
87
  const transfer = {
60
88
  transactionRequest: {
61
- chain: getCachedChain(data.transactionRequest.chainId),
62
- client: params.client,
63
- data: data.transactionRequest.data,
64
- to: data.transactionRequest.to,
65
- value: BigInt(data.transactionRequest.value),
89
+ ...tx,
66
90
  extraGas: 50000n, // extra gas buffer
67
91
  },
68
- approvalData: data.approval,
69
- fromAddress: data.fromAddress,
70
- toAddress: data.toAddress,
71
- paymentToken: data.paymentToken,
72
- processingFee: data.processingFee,
73
- estimatedGasCostUSDCents: data.estimatedGasCostUSDCents,
92
+ approvalData,
93
+ fromAddress: params.fromAddress,
94
+ toAddress: params.toAddress,
95
+ paymentToken: {
96
+ token: {
97
+ tokenAddress: firstStep.originToken.address,
98
+ chainId: firstStep.originToken.chainId,
99
+ decimals: firstStep.originToken.decimals,
100
+ symbol: firstStep.originToken.symbol,
101
+ name: firstStep.originToken.name,
102
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
103
+ },
104
+ amountWei: quote.originAmount.toString(),
105
+ amount: Value.format(quote.originAmount, firstStep.originToken.decimals).toString(),
106
+ amountUSDCents: Number(Value.format(quote.originAmount, firstStep.originToken.decimals)) *
107
+ firstStep.originToken.priceUsd *
108
+ 100,
109
+ },
110
+ processingFee: {
111
+ token: {
112
+ tokenAddress: firstStep.originToken.address,
113
+ chainId: firstStep.originToken.chainId,
114
+ decimals: firstStep.originToken.decimals,
115
+ symbol: firstStep.originToken.symbol,
116
+ name: firstStep.originToken.name,
117
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
118
+ },
119
+ amountWei: params.feePayer === "sender"
120
+ ? (quote.originAmount - quote.destinationAmount).toString()
121
+ : "0",
122
+ amount: params.feePayer === "sender"
123
+ ? Value.format(quote.originAmount - quote.destinationAmount, firstStep.originToken.decimals).toString()
124
+ : "0",
125
+ amountUSDCents: params.feePayer === "sender"
126
+ ? Number(Value.format(quote.originAmount - quote.destinationAmount, firstStep.originToken.decimals)) *
127
+ firstStep.originToken.priceUsd *
128
+ 100
129
+ : 0,
130
+ },
131
+ estimatedGasCostUSDCents: 0,
74
132
  client: params.client,
75
133
  };
76
134
  return transfer;
@@ -1 +1 @@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,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;oBAC3D,CAAC,CAAC,GAAG;gBACT,MAAM,EACJ,MAAM,CAAC,QAAQ,KAAK,QAAQ;oBAC1B,CAAC,CAAC,KAAK,CAAC,MAAM,CACV,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,iBAAiB,EAC5C,SAAS,CAAC,WAAW,CAAC,QAAQ,CAC/B,CAAC,QAAQ,EAAE;oBACd,CAAC,CAAC,GAAG;gBACT,cAAc,EACZ,MAAM,CAAC,QAAQ,KAAK,QAAQ;oBAC1B,CAAC,CAAC,MAAM,CACJ,KAAK,CAAC,MAAM,CACV,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,iBAAiB,EAC5C,SAAS,CAAC,WAAW,CAAC,QAAQ,CAC/B,CACF;wBACD,SAAS,CAAC,WAAW,CAAC,QAAQ;wBAC9B,GAAG;oBACL,CAAC,CAAC,CAAC;aACR;YACD,wBAAwB,EAAE,CAAC;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QAC/D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,6 +1,9 @@
1
- import { getClientFetch } from "../../utils/fetch.js";
2
- import { stringify } from "../../utils/json.js";
3
- import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
1
+ import { prepare as prepareOnramp } from "../../bridge/Onramp.js";
2
+ import { getCachedChain } from "../../chains/utils.js";
3
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
4
+ import { getContract } from "../../contract/contract.js";
5
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
6
+ import { toTokens, toUnits } from "../../utils/units.js";
4
7
  /**
5
8
  * Get a quote of type [`BuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatQuote) to buy given token with fiat currency.
6
9
  * This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.
@@ -51,38 +54,131 @@ import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
51
54
  */
52
55
  export async function getBuyWithFiatQuote(params) {
53
56
  try {
54
- const clientFetch = getClientFetch(params.client);
55
- const response = await clientFetch(getPayBuyWithFiatQuoteEndpoint(), {
56
- method: "POST",
57
- headers: {
58
- Accept: "application/json",
59
- "Content-Type": "application/json",
60
- },
61
- body: stringify({
62
- toAddress: params.toAddress,
63
- fromCurrencySymbol: params.fromCurrencySymbol,
64
- toChainId: params.toChainId.toString(),
65
- toTokenAddress: params.toTokenAddress,
66
- fromAmount: params.fromAmount,
67
- toAmount: params.toAmount,
68
- maxSlippageBPS: params.maxSlippageBPS,
69
- isTestMode: params.isTestMode,
70
- purchaseData: params.purchaseData,
71
- fromAddress: params.fromAddress,
72
- toGasAmountWei: params.toGasAmountWei,
73
- preferredProvider: params.preferredProvider,
74
- multiHopSupported: true,
75
- }),
76
- });
77
- // Assuming the response directly matches the SwapResponse interface
78
- if (!response.ok) {
79
- const errorObj = await response.json();
80
- if (errorObj && "error" in errorObj) {
81
- throw errorObj;
57
+ // map preferred provider (FiatProvider) → onramp string expected by Onramp.prepare
58
+ const mapProviderToOnramp = (provider) => {
59
+ switch (provider) {
60
+ case "STRIPE":
61
+ return "stripe";
62
+ case "TRANSAK":
63
+ return "transak";
64
+ default: // default to coinbase when undefined or any other value
65
+ return "coinbase";
82
66
  }
83
- throw new Error(`HTTP error! status: ${response.status}`);
67
+ };
68
+ // Choose provider or default to STRIPE
69
+ const onrampProvider = mapProviderToOnramp(params.preferredProvider);
70
+ const d = params.toTokenAddress !== NATIVE_TOKEN_ADDRESS
71
+ ? await decimals({
72
+ contract: getContract({
73
+ client: params.client,
74
+ address: params.toTokenAddress,
75
+ chain: getCachedChain(params.toChainId),
76
+ }),
77
+ })
78
+ : 18;
79
+ // Prepare amount in wei if provided
80
+ const amountWei = params.toAmount ? toUnits(params.toAmount, d) : undefined;
81
+ // Call new Onramp.prepare to get the quote & link
82
+ const prepared = await prepareOnramp({
83
+ client: params.client,
84
+ onramp: onrampProvider,
85
+ chainId: params.toChainId,
86
+ tokenAddress: params.toTokenAddress,
87
+ receiver: params.toAddress,
88
+ sender: params.fromAddress,
89
+ amount: amountWei,
90
+ purchaseData: params.purchaseData,
91
+ currency: params.fromCurrencySymbol,
92
+ maxSteps: 2,
93
+ onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
94
+ });
95
+ // Determine tokens based on steps rules
96
+ const hasSteps = prepared.steps.length > 0;
97
+ const firstStep = hasSteps
98
+ ? prepared.steps[0]
99
+ : undefined;
100
+ // Estimated duration in seconds – sum of all step durations
101
+ const estimatedDurationSeconds = Math.max(120, Math.ceil(prepared.steps.reduce((acc, s) => acc + s.estimatedExecutionTimeMs, 0) /
102
+ 1000));
103
+ const estimatedToAmountMinWeiBigInt = prepared.destinationAmount;
104
+ const maxSlippageBPS = params.maxSlippageBPS ?? 0;
105
+ const slippageWei = (estimatedToAmountMinWeiBigInt * BigInt(maxSlippageBPS)) / 10000n;
106
+ const toAmountMinWeiBigInt = estimatedToAmountMinWeiBigInt - slippageWei;
107
+ const estimatedToAmountMin = toTokens(estimatedToAmountMinWeiBigInt, d);
108
+ const toAmountMin = toTokens(toAmountMinWeiBigInt, d);
109
+ // Helper to convert a Token → PayTokenInfo
110
+ const tokenToPayTokenInfo = (token) => ({
111
+ chainId: token.chainId,
112
+ tokenAddress: token.address,
113
+ decimals: token.decimals,
114
+ priceUSDCents: Math.round(token.priceUsd * 100),
115
+ name: token.name,
116
+ symbol: token.symbol,
117
+ });
118
+ // Determine the raw token objects using new simplified rules
119
+ // 1. toToken is always the destination token
120
+ const toTokenRaw = prepared.destinationToken;
121
+ // 2. onRampToken: if exactly one step -> originToken of that step, else toTokenRaw
122
+ const onRampTokenRaw = prepared.steps.length > 0 && firstStep
123
+ ? firstStep.originToken
124
+ : toTokenRaw;
125
+ // 3. routingToken: if exactly two steps -> originToken of second step, else undefined
126
+ const routingTokenRaw = prepared.steps.length > 1
127
+ ? prepared.steps[1].originToken
128
+ : undefined;
129
+ // Amounts for onRampToken/raw
130
+ const onRampTokenAmountWei = prepared.steps.length > 0 && firstStep
131
+ ? firstStep.originAmount
132
+ : prepared.destinationAmount;
133
+ const onRampTokenAmount = toTokens(onRampTokenAmountWei, onRampTokenRaw.decimals);
134
+ // Build info objects
135
+ const onRampTokenObject = {
136
+ amount: onRampTokenAmount,
137
+ amountWei: onRampTokenAmountWei.toString(),
138
+ amountUSDCents: Math.round(Number(onRampTokenAmount) * onRampTokenRaw.priceUsd * 100),
139
+ token: tokenToPayTokenInfo(onRampTokenRaw),
140
+ };
141
+ let routingTokenObject;
142
+ if (routingTokenRaw) {
143
+ const routingAmountWei = prepared.steps[1].originAmount;
144
+ const routingAmount = toTokens(routingAmountWei, routingTokenRaw.decimals);
145
+ routingTokenObject = {
146
+ amount: routingAmount,
147
+ amountWei: routingAmountWei.toString(),
148
+ amountUSDCents: Math.round(Number(routingAmount) * routingTokenRaw.priceUsd * 100),
149
+ token: tokenToPayTokenInfo(routingTokenRaw),
150
+ };
84
151
  }
85
- return (await response.json()).result;
152
+ const buyWithFiatQuote = {
153
+ estimatedDurationSeconds,
154
+ estimatedToAmountMin: estimatedToAmountMin,
155
+ estimatedToAmountMinWei: estimatedToAmountMinWeiBigInt.toString(),
156
+ toAmountMinWei: toAmountMinWeiBigInt.toString(),
157
+ toAmountMin: toAmountMin,
158
+ fromCurrency: {
159
+ amount: prepared.currencyAmount.toString(),
160
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
161
+ decimals: 2,
162
+ currencySymbol: prepared.currency,
163
+ },
164
+ fromCurrencyWithFees: {
165
+ amount: prepared.currencyAmount.toString(),
166
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
167
+ decimals: 2,
168
+ currencySymbol: prepared.currency,
169
+ },
170
+ toToken: tokenToPayTokenInfo(toTokenRaw),
171
+ toAddress: params.toAddress,
172
+ fromAddress: params.fromAddress,
173
+ maxSlippageBPS: maxSlippageBPS,
174
+ intentId: prepared.id,
175
+ processingFees: [],
176
+ onRampToken: onRampTokenObject,
177
+ routingToken: routingTokenObject,
178
+ onRampLink: prepared.link,
179
+ provider: (params.preferredProvider ?? "COINBASE"),
180
+ };
181
+ return buyWithFiatQuote;
86
182
  }
87
183
  catch (error) {
88
184
  console.error("Error getting buy with fiat quote", error);
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/pay/buyWithFiat/getQuote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AA2NzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAiC;IAEjC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,8BAA8B,EAAE,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,SAAS,CAAC;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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