thirdweb 5.100.2-nightly-88533d9113dc07c97cfaf0162591477c7056e69b-20250522000412 → 5.100.2-nightly-5ab59ff400cc32caa414354855fa07831ed90f3a-20250523000413

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 (212) hide show
  1. package/dist/cjs/bridge/Buy.js +15 -3
  2. package/dist/cjs/bridge/Buy.js.map +1 -1
  3. package/dist/cjs/bridge/Chains.js +7 -1
  4. package/dist/cjs/bridge/Chains.js.map +1 -1
  5. package/dist/cjs/bridge/Onramp.js +11 -2
  6. package/dist/cjs/bridge/Onramp.js.map +1 -1
  7. package/dist/cjs/bridge/OnrampStatus.js +7 -1
  8. package/dist/cjs/bridge/OnrampStatus.js.map +1 -1
  9. package/dist/cjs/bridge/Routes.js +7 -1
  10. package/dist/cjs/bridge/Routes.js.map +1 -1
  11. package/dist/cjs/bridge/Sell.js +15 -3
  12. package/dist/cjs/bridge/Sell.js.map +1 -1
  13. package/dist/cjs/bridge/Status.js +7 -1
  14. package/dist/cjs/bridge/Status.js.map +1 -1
  15. package/dist/cjs/bridge/Transfer.js +9 -2
  16. package/dist/cjs/bridge/Transfer.js.map +1 -1
  17. package/dist/cjs/bridge/types/Errors.js +31 -0
  18. package/dist/cjs/bridge/types/Errors.js.map +1 -0
  19. package/dist/cjs/exports/react.js +6 -4
  20. package/dist/cjs/exports/react.js.map +1 -1
  21. package/dist/cjs/exports/react.native.js +6 -4
  22. package/dist/cjs/exports/react.native.js.map +1 -1
  23. package/dist/cjs/pay/buyWithCrypto/getQuote.js +2 -0
  24. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  25. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +1 -0
  26. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
  27. package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js +2 -1
  28. package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
  29. package/dist/cjs/pay/buyWithFiat/getQuote.js +1 -0
  30. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  31. package/dist/cjs/react/core/hooks/wallets/useAuthToken.js +42 -0
  32. package/dist/cjs/react/core/hooks/wallets/useAuthToken.js.map +1 -0
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +4 -4
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js +1 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +4 -8
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +3 -0
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +2 -5
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
  45. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
  46. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  47. package/dist/cjs/react/web/ui/PayEmbed.js +1 -1
  48. package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
  49. package/dist/cjs/react/web/utils/errors.js +20 -1
  50. package/dist/cjs/react/web/utils/errors.js.map +1 -1
  51. package/dist/cjs/utils/ens/avatar.js +1 -1
  52. package/dist/cjs/utils/ens/avatar.js.map +1 -1
  53. package/dist/cjs/version.js +1 -1
  54. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +17 -0
  55. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  56. package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
  57. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  58. package/dist/esm/bridge/Buy.js +15 -3
  59. package/dist/esm/bridge/Buy.js.map +1 -1
  60. package/dist/esm/bridge/Chains.js +7 -1
  61. package/dist/esm/bridge/Chains.js.map +1 -1
  62. package/dist/esm/bridge/Onramp.js +11 -2
  63. package/dist/esm/bridge/Onramp.js.map +1 -1
  64. package/dist/esm/bridge/OnrampStatus.js +7 -1
  65. package/dist/esm/bridge/OnrampStatus.js.map +1 -1
  66. package/dist/esm/bridge/Routes.js +7 -1
  67. package/dist/esm/bridge/Routes.js.map +1 -1
  68. package/dist/esm/bridge/Sell.js +15 -3
  69. package/dist/esm/bridge/Sell.js.map +1 -1
  70. package/dist/esm/bridge/Status.js +7 -1
  71. package/dist/esm/bridge/Status.js.map +1 -1
  72. package/dist/esm/bridge/Transfer.js +9 -2
  73. package/dist/esm/bridge/Transfer.js.map +1 -1
  74. package/dist/esm/bridge/types/Errors.js +27 -0
  75. package/dist/esm/bridge/types/Errors.js.map +1 -0
  76. package/dist/esm/exports/react.js +2 -1
  77. package/dist/esm/exports/react.js.map +1 -1
  78. package/dist/esm/exports/react.native.js +2 -1
  79. package/dist/esm/exports/react.native.js.map +1 -1
  80. package/dist/esm/pay/buyWithCrypto/getQuote.js +2 -0
  81. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  82. package/dist/esm/pay/buyWithCrypto/getTransfer.js +1 -0
  83. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
  84. package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js +2 -1
  85. package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
  86. package/dist/esm/pay/buyWithFiat/getQuote.js +1 -0
  87. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  88. package/dist/esm/react/core/hooks/wallets/useAuthToken.js +39 -0
  89. package/dist/esm/react/core/hooks/wallets/useAuthToken.js.map +1 -0
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +4 -4
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js +1 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +4 -8
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +3 -0
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +2 -5
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -1
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  101. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
  102. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
  103. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  104. package/dist/esm/react/web/ui/PayEmbed.js +1 -1
  105. package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
  106. package/dist/esm/react/web/utils/errors.js +20 -1
  107. package/dist/esm/react/web/utils/errors.js.map +1 -1
  108. package/dist/esm/utils/ens/avatar.js +1 -1
  109. package/dist/esm/utils/ens/avatar.js.map +1 -1
  110. package/dist/esm/version.js +1 -1
  111. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +17 -0
  112. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  113. package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
  114. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  115. package/dist/types/bridge/Buy.d.ts +4 -0
  116. package/dist/types/bridge/Buy.d.ts.map +1 -1
  117. package/dist/types/bridge/Chains.d.ts.map +1 -1
  118. package/dist/types/bridge/Onramp.d.ts +4 -0
  119. package/dist/types/bridge/Onramp.d.ts.map +1 -1
  120. package/dist/types/bridge/OnrampStatus.d.ts.map +1 -1
  121. package/dist/types/bridge/Routes.d.ts.map +1 -1
  122. package/dist/types/bridge/Sell.d.ts +4 -0
  123. package/dist/types/bridge/Sell.d.ts.map +1 -1
  124. package/dist/types/bridge/Status.d.ts.map +1 -1
  125. package/dist/types/bridge/Transfer.d.ts +4 -0
  126. package/dist/types/bridge/Transfer.d.ts.map +1 -1
  127. package/dist/types/bridge/index.d.ts +2 -1
  128. package/dist/types/bridge/index.d.ts.map +1 -1
  129. package/dist/types/bridge/types/BridgeAction.d.ts +1 -1
  130. package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -1
  131. package/dist/types/bridge/types/Errors.d.ts +14 -0
  132. package/dist/types/bridge/types/Errors.d.ts.map +1 -0
  133. package/dist/types/bridge/types/Route.d.ts +2 -2
  134. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  135. package/dist/types/exports/react.d.ts +2 -1
  136. package/dist/types/exports/react.d.ts.map +1 -1
  137. package/dist/types/exports/react.native.d.ts +2 -1
  138. package/dist/types/exports/react.native.d.ts.map +1 -1
  139. package/dist/types/pay/buyWithCrypto/getQuote.d.ts +4 -0
  140. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  141. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts +4 -0
  142. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
  143. package/dist/types/pay/buyWithFiat/getPostOnRampQuote.d.ts +5 -1
  144. package/dist/types/pay/buyWithFiat/getPostOnRampQuote.d.ts.map +1 -1
  145. package/dist/types/pay/buyWithFiat/getQuote.d.ts +4 -0
  146. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  147. package/dist/types/react/core/hooks/wallets/useAuthToken.d.ts +26 -0
  148. package/dist/types/react/core/hooks/wallets/useAuthToken.d.ts.map +1 -0
  149. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts +1 -0
  150. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
  151. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts +1 -0
  152. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts.map +1 -1
  153. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts +1 -0
  154. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
  155. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts +1 -0
  156. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts.map +1 -1
  157. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts +1 -0
  158. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
  159. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +1 -0
  160. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -1
  161. package/dist/types/react/web/ui/PayEmbed.d.ts +4 -0
  162. package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
  163. package/dist/types/react/web/utils/errors.d.ts +2 -8
  164. package/dist/types/react/web/utils/errors.d.ts.map +1 -1
  165. package/dist/types/version.d.ts +1 -1
  166. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts +2 -0
  167. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts.map +1 -1
  168. package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
  169. package/dist/types/wallets/in-app/native/native-connector.d.ts +2 -1
  170. package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
  171. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +2 -1
  172. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
  173. package/dist/types/wallets/interfaces/wallet.d.ts +10 -0
  174. package/dist/types/wallets/interfaces/wallet.d.ts.map +1 -1
  175. package/package.json +1 -1
  176. package/src/bridge/Buy.ts +19 -6
  177. package/src/bridge/Chains.ts +7 -1
  178. package/src/bridge/Onramp.ts +16 -3
  179. package/src/bridge/OnrampStatus.ts +7 -3
  180. package/src/bridge/Routes.test.ts +1 -1
  181. package/src/bridge/Routes.ts +7 -1
  182. package/src/bridge/Sell.ts +19 -6
  183. package/src/bridge/Status.ts +7 -3
  184. package/src/bridge/Transfer.ts +13 -3
  185. package/src/bridge/index.ts +2 -1
  186. package/src/bridge/types/BridgeAction.ts +1 -1
  187. package/src/bridge/types/Errors.ts +24 -0
  188. package/src/bridge/types/Route.ts +2 -2
  189. package/src/exports/react.native.ts +2 -1
  190. package/src/exports/react.ts +2 -1
  191. package/src/pay/buyWithCrypto/getQuote.ts +7 -0
  192. package/src/pay/buyWithCrypto/getTransfer.ts +6 -0
  193. package/src/pay/buyWithFiat/getPostOnRampQuote.ts +7 -0
  194. package/src/pay/buyWithFiat/getQuote.ts +6 -0
  195. package/src/react/core/hooks/wallets/useAuthToken.ts +41 -0
  196. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +6 -0
  197. package/src/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.tsx +1 -1
  198. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +36 -69
  199. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +6 -0
  200. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx +9 -38
  201. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +3 -0
  202. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +1 -0
  203. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +1 -1
  204. package/src/react/web/ui/PayEmbed.tsx +6 -0
  205. package/src/react/web/utils/errors.ts +24 -8
  206. package/src/utils/ens/avatar.ts +1 -1
  207. package/src/version.ts +1 -1
  208. package/src/wallets/in-app/core/interfaces/connector.ts +2 -0
  209. package/src/wallets/in-app/core/wallet/in-app-core.ts +15 -0
  210. package/src/wallets/in-app/native/native-connector.ts +1 -1
  211. package/src/wallets/in-app/web/lib/web-connector.ts +1 -1
  212. package/src/wallets/interfaces/wallet.ts +11 -1
@@ -40,10 +40,11 @@ export type { MediaRendererProps } from "../react/web/ui/MediaRenderer/types.js"
40
40
 
41
41
  // wallet hooks
42
42
  export { useActiveWallet } from "../react/core/hooks/wallets/useActiveWallet.js";
43
- export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
44
43
  export { useActiveWalletChain } from "../react/core/hooks/wallets/useActiveWalletChain.js";
45
44
  export { useActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useActiveWalletConnectionStatus.js";
46
45
  export { useActiveAccount } from "../react/core/hooks/wallets/useActiveAccount.js";
46
+ export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
47
+ export { useAuthToken } from "../react/core/hooks/wallets/useAuthToken.js";
47
48
  export { useAutoConnect } from "../react/web/hooks/wallets/useAutoConnect.js";
48
49
  export { useConnect } from "../react/core/hooks/wallets/useConnect.js";
49
50
  export { useConnectedWallets } from "../react/core/hooks/wallets/useConnectedWallets.js";
@@ -83,6 +83,11 @@ export type GetBuyWithCryptoQuoteParams = {
83
83
  * For example, if you want to allow a maximum slippage of 0.5%, you should specify `50` bps.
84
84
  */
85
85
  maxSlippageBPS?: number;
86
+
87
+ /**
88
+ * @hidden
89
+ */
90
+ paymentLinkId?: string;
86
91
  } & (
87
92
  | {
88
93
  /**
@@ -203,6 +208,7 @@ export async function getBuyWithCryptoQuote(
203
208
  amount: amount,
204
209
  purchaseData: params.purchaseData,
205
210
  client: params.client,
211
+ paymentLinkId: params.paymentLinkId,
206
212
  });
207
213
  } else if (params.fromAmount) {
208
214
  const originTokenContract = getContract({
@@ -224,6 +230,7 @@ export async function getBuyWithCryptoQuote(
224
230
  amount: amount,
225
231
  purchaseData: params.purchaseData,
226
232
  client: params.client,
233
+ paymentLinkId: params.paymentLinkId,
227
234
  });
228
235
  }
229
236
  throw new Error(
@@ -60,6 +60,11 @@ export type GetBuyWithCryptoTransferParams = {
60
60
  * For direct transfers, specify who will pay for the transfer fee. Can be "sender" or "receiver".
61
61
  */
62
62
  feePayer?: "sender" | "receiver";
63
+
64
+ /**
65
+ * @hidden
66
+ */
67
+ paymentLinkId?: string;
63
68
  };
64
69
 
65
70
  /**
@@ -127,6 +132,7 @@ export async function getBuyWithCryptoTransfer(
127
132
  receiver: params.toAddress,
128
133
  client: params.client,
129
134
  feePayer: params.feePayer,
135
+ paymentLinkId: params.paymentLinkId,
130
136
  });
131
137
 
132
138
  const firstStep = quote.steps[0];
@@ -21,6 +21,11 @@ export type GetPostOnRampQuoteParams = {
21
21
  * The "Buy with fiat" transaction status object returned by [`getBuyWithFiatStatus`](https://portal.thirdweb.com/typescript/v5/getBuyWithFiatStatus) function
22
22
  */
23
23
  buyWithFiatStatus: BuyWithFiatStatus;
24
+
25
+ /**
26
+ * @hidden
27
+ */
28
+ paymentLinkId?: string;
24
29
  };
25
30
 
26
31
  /**
@@ -61,6 +66,7 @@ export type GetPostOnRampQuoteParams = {
61
66
  export async function getPostOnRampQuote({
62
67
  client,
63
68
  buyWithFiatStatus,
69
+ paymentLinkId,
64
70
  }: GetPostOnRampQuoteParams): Promise<BuyWithCryptoQuote> {
65
71
  if (buyWithFiatStatus.status === "NOT_FOUND") {
66
72
  throw new Error("Invalid buyWithFiatStatus");
@@ -77,5 +83,6 @@ export async function getPostOnRampQuote({
77
83
  toChainId: buyWithFiatStatus.quote.toToken.chainId,
78
84
  toTokenAddress: buyWithFiatStatus.quote.toToken.tokenAddress,
79
85
  toAmount: buyWithFiatStatus.quote.estimatedToTokenAmount,
86
+ paymentLinkId: paymentLinkId,
80
87
  });
81
88
  }
@@ -95,6 +95,11 @@ export type GetBuyWithFiatQuoteParams = {
95
95
  * By default, we choose a recommended provider based on the location of the user, KYC status, and currency.
96
96
  */
97
97
  preferredProvider?: FiatProvider;
98
+
99
+ /**
100
+ * @hidden
101
+ */
102
+ paymentLinkId?: string;
98
103
  };
99
104
 
100
105
  /**
@@ -321,6 +326,7 @@ export async function getBuyWithFiatQuote(
321
326
  currency: params.fromCurrencySymbol,
322
327
  maxSteps: 2,
323
328
  onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
329
+ paymentLinkId: params.paymentLinkId,
324
330
  });
325
331
 
326
332
  // Determine tokens based on steps rules
@@ -0,0 +1,41 @@
1
+ import { useActiveAccount } from "./useActiveAccount.js";
2
+ import { useActiveWallet } from "./useActiveWallet.js";
3
+
4
+ /**
5
+ * A hook that returns the authentication token (JWT) for the currently active wallet.
6
+ * This token can be used to authorize API calls to your backend server.
7
+ *
8
+ * @returns The JWT string if the active wallet is an in-app wallet and matches the active account, null otherwise
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function MyComponent() {
13
+ * const authToken = useAuthToken();
14
+ *
15
+ * const fetchData = async () => {
16
+ * const response = await fetch('https://api.example.com/data', {
17
+ * headers: {
18
+ * 'Authorization': `Bearer ${authToken}`
19
+ * }
20
+ * });
21
+ * // ... handle response
22
+ * };
23
+ * }
24
+ * ```
25
+ *
26
+ * @wallet
27
+ */
28
+ export function useAuthToken() {
29
+ const activeWallet = useActiveWallet();
30
+ const activeAccount = useActiveAccount();
31
+ // if the active wallet is an in-app wallet and the active account is the same as the active wallet's account, return the auth token for the in-app wallet
32
+ if (
33
+ activeWallet?.getAuthToken &&
34
+ activeAccount &&
35
+ activeAccount.address === activeWallet.getAccount()?.address
36
+ ) {
37
+ return activeWallet.getAuthToken();
38
+ }
39
+ // all other wallets don't expose an auth token for now
40
+ return null;
41
+ }
@@ -83,6 +83,7 @@ export type BuyScreenProps = {
83
83
  connectOptions: PayEmbedConnectOptions | undefined;
84
84
  hiddenWallets?: WalletId[];
85
85
  isEmbed: boolean;
86
+ paymentLinkId?: string;
86
87
  };
87
88
 
88
89
  /**
@@ -151,6 +152,7 @@ type BuyScreenContentProps = {
151
152
  hiddenWallets?: WalletId[];
152
153
  connectOptions: PayEmbedConnectOptions | undefined;
153
154
  isEmbed: boolean;
155
+ paymentLinkId?: string;
154
156
  };
155
157
 
156
158
  /**
@@ -347,6 +349,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
347
349
  <OnRampScreen
348
350
  title={props.title}
349
351
  transactionMode={payOptions.mode === "transaction"}
352
+ paymentLinkId={props.paymentLinkId}
350
353
  quote={screen.quote}
351
354
  onBack={() => {
352
355
  setScreen({
@@ -395,6 +398,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
395
398
  });
396
399
  }}
397
400
  onSuccess={onSwapSuccess}
401
+ paymentLinkId={props.paymentLinkId}
398
402
  />
399
403
  );
400
404
  }
@@ -530,6 +534,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
530
534
  {screen.id === "buy-with-crypto" && activeAccount && (
531
535
  <SwapScreenContent
532
536
  setScreen={setScreen}
537
+ paymentLinkId={props.paymentLinkId}
533
538
  tokenAmount={deferredTokenAmount}
534
539
  toChain={toChain}
535
540
  toToken={toToken}
@@ -585,6 +590,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
585
590
  payer={payer}
586
591
  setTokenAmount={setTokenAmount}
587
592
  setHasEditedAmount={setHasEditedAmount}
593
+ paymentLinkId={props.paymentLinkId}
588
594
  />
589
595
  )}
590
596
 
@@ -85,7 +85,7 @@ export function PayWithCreditCard(props: {
85
85
  {props.value
86
86
  ? `${props.currency.symbol}${formatNumber(
87
87
  Number(props.value),
88
- 6,
88
+ 2,
89
89
  )}`
90
90
  : "--"}
91
91
  </Text>
@@ -5,7 +5,6 @@ import type { Chain } from "../../../../../../../chains/types.js";
5
5
  import type { ThirdwebClient } from "../../../../../../../client/client.js";
6
6
  import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
7
7
  import type { FiatProvider } from "../../../../../../../pay/utils/commonTypes.js";
8
- import { formatNumber } from "../../../../../../../utils/formatNumber.js";
9
8
  import {
10
9
  type Theme,
11
10
  iconSize,
@@ -25,7 +24,6 @@ import { Spinner } from "../../../../components/Spinner.js";
25
24
  import { Container } from "../../../../components/basic.js";
26
25
  import { Button } from "../../../../components/buttons.js";
27
26
  import { Text } from "../../../../components/text.js";
28
- import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
29
27
  import { type ERC20OrNativeToken, isNativeToken } from "../../nativeToken.js";
30
28
  import { EstimatedTimeAndFees } from "../EstimatedTimeAndFees.js";
31
29
  import { PayWithCreditCard } from "../PayWIthCreditCard.js";
@@ -50,6 +48,7 @@ export function FiatScreenContent(props: {
50
48
  payer: PayerInfo;
51
49
  setTokenAmount: (amount: string) => void;
52
50
  setHasEditedAmount: (hasEdited: boolean) => void;
51
+ paymentLinkId: undefined | string;
53
52
  }) {
54
53
  const {
55
54
  toToken,
@@ -60,6 +59,7 @@ export function FiatScreenContent(props: {
60
59
  toChain,
61
60
  showCurrencySelector,
62
61
  selectedCurrency,
62
+ paymentLinkId,
63
63
  } = props;
64
64
  const defaultRecipientAddress = (
65
65
  props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
@@ -99,6 +99,7 @@ export function FiatScreenContent(props: {
99
99
  purchaseData: props.payOptions.purchaseData,
100
100
  fromAddress: payer.account.address,
101
101
  preferredProvider: preferredProvider,
102
+ paymentLinkId: paymentLinkId,
102
103
  }
103
104
  : undefined,
104
105
  );
@@ -227,77 +228,43 @@ export function FiatScreenContent(props: {
227
228
  {/* Error message */}
228
229
  {errorMsg && (
229
230
  <div>
230
- {errorMsg.data?.minimumAmountEth ? (
231
- <Text color="danger" size="sm" center multiline>
232
- Minimum amount is{" "}
233
- {formatNumber(Number(errorMsg.data.minimumAmountEth), 6)}{" "}
234
- <TokenSymbol
235
- token={toToken}
236
- chain={toChain}
237
- size="sm"
238
- inline
239
- color="danger"
240
- />
241
- </Text>
242
- ) : (
243
- <div>
244
- <Text color="danger" size="xs" center multiline>
245
- {errorMsg.title}
246
- </Text>
247
- <Text size="xs" center multiline>
248
- {errorMsg.message}
249
- </Text>
250
- </div>
251
- )}
231
+ <Text color="danger" size="xs" center multiline>
232
+ {errorMsg.title}
233
+ </Text>
234
+ <Text size="xs" center multiline>
235
+ {errorMsg.message}
236
+ </Text>
252
237
  </div>
253
238
  )}
254
239
  </Container>
255
240
 
256
- {errorMsg?.data?.minimumAmountEth ? (
257
- <Button
258
- variant="accent"
259
- fullWidth
260
- onClick={() => {
261
- props.setTokenAmount(
262
- formatNumber(
263
- Number(errorMsg.data?.minimumAmountEth),
264
- 6,
265
- ).toString(),
266
- );
267
- props.setHasEditedAmount(true);
268
- }}
269
- >
270
- Set Minimum
271
- </Button>
272
- ) : (
273
- <Button
274
- variant={disableSubmit ? "outline" : "accent"}
275
- data-disabled={disableSubmit}
276
- disabled={disableSubmit}
277
- fullWidth
278
- onClick={() => {
279
- trackPayEvent({
280
- event: "confirm_onramp_quote",
281
- client: client,
282
- walletAddress: payer.account.address,
283
- walletType: payer.wallet.id,
284
- toChainId: toChain.id,
285
- toToken: isNativeToken(toToken) ? undefined : toToken.address,
286
- });
287
- handleSubmit();
288
- }}
289
- gap="xs"
290
- >
291
- {fiatQuoteQuery.isLoading ? (
292
- <>
293
- Getting price quote
294
- <Spinner size="sm" color="accentButtonText" />
295
- </>
296
- ) : (
297
- "Continue"
298
- )}
299
- </Button>
300
- )}
241
+ <Button
242
+ variant={disableSubmit ? "outline" : "accent"}
243
+ data-disabled={disableSubmit}
244
+ disabled={disableSubmit}
245
+ fullWidth
246
+ onClick={() => {
247
+ trackPayEvent({
248
+ event: "confirm_onramp_quote",
249
+ client: client,
250
+ walletAddress: payer.account.address,
251
+ walletType: payer.wallet.id,
252
+ toChainId: toChain.id,
253
+ toToken: isNativeToken(toToken) ? undefined : toToken.address,
254
+ });
255
+ handleSubmit();
256
+ }}
257
+ gap="xs"
258
+ >
259
+ {fiatQuoteQuery.isLoading ? (
260
+ <>
261
+ Getting price quote
262
+ <Spinner size="sm" color="accentButtonText" />
263
+ </>
264
+ ) : (
265
+ "Continue"
266
+ )}
267
+ </Button>
301
268
  </Container>
302
269
  );
303
270
  }
@@ -71,6 +71,7 @@ export function OnRampScreen(props: {
71
71
  payer: PayerInfo;
72
72
  onSuccess: (status: BuyWithFiatStatus) => void;
73
73
  receiverAddress: string;
74
+ paymentLinkId?: string;
74
75
  }) {
75
76
  const connectedWallets = useConnectedWallets();
76
77
  const isAutoMode = isInAppSigner({
@@ -85,6 +86,7 @@ export function OnRampScreen(props: {
85
86
  payer: props.payer,
86
87
  theme: props.theme,
87
88
  isAutoMode,
89
+ paymentLinkId: props.paymentLinkId,
88
90
  });
89
91
  const firstStepChainId = state.steps[0]?.step.token.chainId;
90
92
  return (
@@ -288,6 +290,7 @@ function useOnRampScreenState(props: {
288
290
  payer: PayerInfo;
289
291
  theme: "light" | "dark";
290
292
  isAutoMode?: boolean;
293
+ paymentLinkId?: string;
291
294
  }): OnRampScreenState {
292
295
  const onRampSteps = getOnRampSteps(props.quote);
293
296
  const [currentStepIndex, setCurrentStepIndex] = useState(0);
@@ -322,6 +325,7 @@ function useOnRampScreenState(props: {
322
325
  client: props.client,
323
326
  payer: props.payer,
324
327
  isFiatFlow: true,
328
+ paymentLinkId: props.paymentLinkId,
325
329
  });
326
330
 
327
331
  // Track swap status
@@ -615,6 +619,7 @@ function useSwapMutation(props: {
615
619
  client: ThirdwebClient;
616
620
  payer: PayerInfo;
617
621
  isFiatFlow: boolean;
622
+ paymentLinkId?: string;
618
623
  }) {
619
624
  const queryClient = useQueryClient();
620
625
  return useMutation({
@@ -646,6 +651,7 @@ function useSwapMutation(props: {
646
651
  toTokenAddress: toToken.tokenAddress,
647
652
  fromAddress: account.address,
648
653
  toAddress: account.address,
654
+ paymentLinkId: props.paymentLinkId,
649
655
  client: props.client,
650
656
  });
651
657
 
@@ -8,7 +8,6 @@ import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.j
8
8
  import { getContract } from "../../../../../../../contract/contract.js";
9
9
  import { allowance } from "../../../../../../../extensions/erc20/__generated__/IERC20/read/allowance.js";
10
10
  import type { GetBuyWithCryptoQuoteParams } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
11
- import { formatNumber } from "../../../../../../../utils/formatNumber.js";
12
11
  import type { Account } from "../../../../../../../wallets/interfaces/wallet.js";
13
12
  import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
14
13
  import { useWalletBalance } from "../../../../../../core/hooks/others/useWalletBalance.js";
@@ -55,6 +54,7 @@ export function SwapScreenContent(props: {
55
54
  setTokenAmount: (amount: string) => void;
56
55
  setHasEditedAmount: (hasEdited: boolean) => void;
57
56
  disableTokenSelection: boolean;
57
+ paymentLinkId: undefined | string;
58
58
  }) {
59
59
  const {
60
60
  setScreen,
@@ -121,6 +121,7 @@ export function SwapScreenContent(props: {
121
121
  toAmount: tokenAmount,
122
122
  client,
123
123
  purchaseData: payOptions.purchaseData,
124
+ paymentLinkId: props.paymentLinkId,
124
125
  }
125
126
  : undefined;
126
127
 
@@ -286,28 +287,14 @@ export function SwapScreenContent(props: {
286
287
  {/* Error message */}
287
288
  {errorMsg && (
288
289
  <div>
289
- {errorMsg.data?.minimumAmountEth ? (
290
+ <div>
290
291
  <Text color="danger" size="xs" center multiline>
291
- Minimum amount is{" "}
292
- {formatNumber(Number(errorMsg.data.minimumAmountEth), 6)}{" "}
293
- <TokenSymbol
294
- token={toToken}
295
- chain={toChain}
296
- size="sm"
297
- inline
298
- color="danger"
299
- />
292
+ {errorMsg.title}
300
293
  </Text>
301
- ) : (
302
- <div>
303
- <Text color="danger" size="xs" center multiline>
304
- {errorMsg.title}
305
- </Text>
306
- <Text size="xs" center multiline>
307
- {errorMsg.message}
308
- </Text>
309
- </div>
310
- )}
294
+ <Text size="xs" center multiline>
295
+ {errorMsg.message}
296
+ </Text>
297
+ </div>
311
298
  </div>
312
299
  )}
313
300
 
@@ -324,23 +311,7 @@ export function SwapScreenContent(props: {
324
311
  </Container>
325
312
 
326
313
  {/* Button */}
327
- {errorMsg?.data?.minimumAmountEth ? (
328
- <Button
329
- variant="accent"
330
- fullWidth
331
- onClick={() => {
332
- props.setTokenAmount(
333
- formatNumber(
334
- Number(errorMsg.data?.minimumAmountEth),
335
- 6,
336
- ).toString(),
337
- );
338
- props.setHasEditedAmount(true);
339
- }}
340
- >
341
- Set Minimum
342
- </Button>
343
- ) : isNotEnoughBalance || errorMsg ? (
314
+ {isNotEnoughBalance || errorMsg ? (
344
315
  <Button
345
316
  variant="accent"
346
317
  fullWidth
@@ -52,6 +52,7 @@ type TransferConfirmationScreenProps = {
52
52
  transactionMode?: boolean;
53
53
  payOptions?: PayUIOptions;
54
54
  onSuccess: ((status: BuyWithCryptoStatus) => void) | undefined;
55
+ paymentLinkId: undefined | string;
55
56
  };
56
57
 
57
58
  export function TransferConfirmationScreen(
@@ -70,6 +71,7 @@ export function TransferConfirmationScreen(
70
71
  transactionMode,
71
72
  setTransactionHash,
72
73
  payOptions,
74
+ paymentLinkId,
73
75
  } = props;
74
76
  const [step, setStep] = useState<"approve" | "transfer" | "execute">(
75
77
  "transfer",
@@ -105,6 +107,7 @@ export function TransferConfirmationScreen(
105
107
  payOptions?.mode === "direct_payment"
106
108
  ? payOptions.paymentInfo.feePayer
107
109
  : undefined,
110
+ paymentLinkId: paymentLinkId,
108
111
  });
109
112
  return transferResponse;
110
113
  },
@@ -23,6 +23,7 @@ type TransferFlowProps = {
23
23
  tokenAmount: string;
24
24
  transactionMode?: boolean;
25
25
  payOptions?: PayUIOptions;
26
+ paymentLinkId: undefined | string;
26
27
  };
27
28
 
28
29
  export function TransferFlow(props: TransferFlowProps) {
@@ -36,7 +36,7 @@ async function fetchBuySupportedDestinations({
36
36
  originTokenAddress,
37
37
  maxSteps: 1,
38
38
  sortBy: "popularity",
39
- limit: 1000000,
39
+ limit: 1_000_000,
40
40
  });
41
41
  const tokens = new Set<string>();
42
42
  const chains = new Set<number>();
@@ -144,6 +144,11 @@ export type PayEmbedProps = {
144
144
  style?: React.CSSProperties;
145
145
 
146
146
  className?: string;
147
+
148
+ /**
149
+ * @hidden
150
+ */
151
+ paymentLinkId?: string;
147
152
  };
148
153
 
149
154
  /**
@@ -365,6 +370,7 @@ export function PayEmbed(props: PayEmbedProps) {
365
370
  client={props.client}
366
371
  connectLocale={localeQuery.data}
367
372
  hiddenWallets={props.hiddenWallets}
373
+ paymentLinkId={props.paymentLinkId}
368
374
  payOptions={
369
375
  props.payOptions || {
370
376
  mode: "fund_wallet",
@@ -1,17 +1,21 @@
1
- type ApiError = {
1
+ import { ApiError } from "../../../bridge/types/Errors.js";
2
+
3
+ type UiError = {
2
4
  code: string;
3
5
  title: string;
4
6
  message: string;
5
- data?: {
6
- minimumAmountUSDCents?: string;
7
- requestedAmountUSDCents?: string;
8
- minimumAmountWei?: string;
9
- minimumAmountEth?: string;
10
- };
11
7
  };
12
8
 
13
9
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
14
- export function getErrorMessage(err: any): ApiError {
10
+ export function getErrorMessage(err: any): UiError {
11
+ if (err instanceof ApiError) {
12
+ return {
13
+ code: err.code,
14
+ title: "Failed to Find Quote",
15
+ message: getErrorMessageFromBridgeApiError(err),
16
+ };
17
+ }
18
+
15
19
  if (typeof err.error === "object" && err.error.code) {
16
20
  if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") {
17
21
  return {
@@ -29,6 +33,18 @@ export function getErrorMessage(err: any): ApiError {
29
33
  code: "UNABLE_TO_GET_PRICE_QUOTE",
30
34
  title: "Failed to Find Quote",
31
35
  message:
36
+ err.message ||
32
37
  "We couldn't get a quote for this token pair. Select another token or pay with card.",
33
38
  };
34
39
  }
40
+
41
+ function getErrorMessageFromBridgeApiError(err: ApiError) {
42
+ let msg = err.message;
43
+ if (msg.includes("Details")) {
44
+ msg = msg.substring(0, msg.indexOf("Details"));
45
+ }
46
+ if (msg.includes("{")) {
47
+ msg = msg.substring(0, msg.indexOf("{"));
48
+ }
49
+ return msg;
50
+ }
@@ -74,7 +74,7 @@ async function isImageUri(options: ParseAvatarOptions): Promise<boolean> {
74
74
  return false;
75
75
  }
76
76
  // fail in NodeJS, since the error is not cors but any other network issue
77
- if (Object.hasOwn(globalThis, "Image")) {
77
+ if (!Object.hasOwn(globalThis, "Image")) {
78
78
  return false;
79
79
  }
80
80
  // in case of cors, use image api to validate if given url is an actual image
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.100.2-nightly-88533d9113dc07c97cfaf0162591477c7056e69b-20250522000412";
1
+ export const version = "5.100.2-nightly-5ab59ff400cc32caa414354855fa07831ed90f3a-20250523000413";
@@ -1,5 +1,6 @@
1
1
  import type { SocialAuthOption } from "../../../../wallets/types.js";
2
2
  import type { Account } from "../../../interfaces/wallet.js";
3
+ import type { ClientScopedStorage } from "../authentication/client-scoped-storage.js";
3
4
  import type {
4
5
  AuthArgsType,
5
6
  AuthLoginReturnType,
@@ -38,4 +39,5 @@ export interface InAppConnector {
38
39
  linkProfile(args: AuthArgsType): Promise<Profile[]>;
39
40
  unlinkProfile(args: Profile): Promise<Profile[]>;
40
41
  getProfiles(): Promise<Profile[]>;
42
+ storage: ClientScopedStorage;
41
43
  }
@@ -55,9 +55,11 @@ export function createInAppWallet(args: {
55
55
  let adminAccount: Account | undefined = undefined; // Admin account if smartAccountOptions were provided with connection
56
56
  let chain: Chain | undefined = undefined;
57
57
  let client: ThirdwebClient | undefined;
58
+ let authToken: string | null = null;
58
59
 
59
60
  return {
60
61
  id: walletId,
62
+ getAuthToken: () => authToken,
61
63
  subscribe: emitter.subscribe,
62
64
  getChain() {
63
65
  if (!chain) {
@@ -114,6 +116,12 @@ export function createInAppWallet(args: {
114
116
  account = connectedAccount;
115
117
  adminAccount = _adminAccount;
116
118
  chain = connectedChain;
119
+ try {
120
+ authToken = await connector.storage.getAuthCookie();
121
+ } catch (error) {
122
+ console.error("Failed to retrieve auth token:", error);
123
+ authToken = null;
124
+ }
117
125
  trackConnect({
118
126
  client: options.client,
119
127
  ecosystem,
@@ -168,6 +176,12 @@ export function createInAppWallet(args: {
168
176
  account = connectedAccount;
169
177
  adminAccount = _adminAccount;
170
178
  chain = connectedChain;
179
+ try {
180
+ authToken = await connector.storage.getAuthCookie();
181
+ } catch (error) {
182
+ console.error("Failed to retrieve auth token:", error);
183
+ authToken = null;
184
+ }
171
185
  trackConnect({
172
186
  client: options.client,
173
187
  ecosystem,
@@ -194,6 +208,7 @@ export function createInAppWallet(args: {
194
208
  account = undefined;
195
209
  adminAccount = undefined;
196
210
  chain = undefined;
211
+ authToken = null;
197
212
  emitter.emit("disconnect", undefined);
198
213
  },
199
214
  switchChain: async (newChain) => {