thirdweb 5.108.1 → 5.108.2

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 (224) hide show
  1. package/dist/cjs/bridge/Buy.js +2 -2
  2. package/dist/cjs/bridge/Chains.js +1 -1
  3. package/dist/cjs/bridge/Routes.js +1 -1
  4. package/dist/cjs/bridge/Sell.js +2 -2
  5. package/dist/cjs/bridge/Status.js +1 -1
  6. package/dist/cjs/bridge/Token.js +3 -3
  7. package/dist/cjs/bridge/Transfer.js +1 -1
  8. package/dist/cjs/bridge/Webhook.js +1 -1
  9. package/dist/cjs/exports/react.js +3 -1
  10. package/dist/cjs/exports/react.js.map +1 -1
  11. package/dist/cjs/exports/thirdweb.js +1 -1
  12. package/dist/cjs/react/core/hooks/useStepExecutor.js +1 -21
  13. package/dist/cjs/react/core/hooks/useStepExecutor.js.map +1 -1
  14. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js +5 -6
  15. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
  16. package/dist/cjs/react/web/ui/Bridge/StepRunner.js +2 -2
  17. package/dist/cjs/react/web/ui/Bridge/StepRunner.js.map +1 -1
  18. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js +1 -0
  19. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  20. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js +95 -0
  21. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -0
  22. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js +1 -0
  23. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
  24. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js +13 -1
  25. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  26. package/dist/cjs/react/web/ui/Bridge/swap-widget/select-chain.js +12 -1
  27. package/dist/cjs/react/web/ui/Bridge/swap-widget/select-chain.js.map +1 -1
  28. package/dist/cjs/react/web/ui/Bridge/swap-widget/select-token-ui.js +13 -4
  29. package/dist/cjs/react/web/ui/Bridge/swap-widget/select-token-ui.js.map +1 -1
  30. package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js +6 -10
  31. package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +2 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  34. package/dist/cjs/script-exports/bridge-widget-script.js +17 -0
  35. package/dist/cjs/script-exports/bridge-widget-script.js.map +1 -0
  36. package/dist/cjs/script-exports/bridge-widget.js +13 -0
  37. package/dist/cjs/script-exports/bridge-widget.js.map +1 -0
  38. package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js +30 -1
  39. package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js.map +1 -1
  40. package/dist/cjs/stories/Bridge/BridgeWidget/bridge-widget-script.stories.js +47 -0
  41. package/dist/cjs/stories/Bridge/BridgeWidget/bridge-widget-script.stories.js.map +1 -0
  42. package/dist/cjs/stories/Bridge/StepRunner.stories.js +1 -21
  43. package/dist/cjs/stories/Bridge/StepRunner.stories.js.map +1 -1
  44. package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js +4 -4
  45. package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
  46. package/dist/cjs/utils/units.js +3 -0
  47. package/dist/cjs/utils/units.js.map +1 -1
  48. package/dist/cjs/version.js +1 -1
  49. package/dist/cjs/x402/common.js +41 -41
  50. package/dist/cjs/x402/common.js.map +1 -1
  51. package/dist/cjs/x402/facilitator.js +1 -0
  52. package/dist/cjs/x402/facilitator.js.map +1 -1
  53. package/dist/cjs/x402/fetchWithPayment.js +1 -1
  54. package/dist/cjs/x402/fetchWithPayment.js.map +1 -1
  55. package/dist/cjs/x402/schemas.js +3 -0
  56. package/dist/cjs/x402/schemas.js.map +1 -1
  57. package/dist/cjs/x402/settle-payment.js +4 -3
  58. package/dist/cjs/x402/settle-payment.js.map +1 -1
  59. package/dist/cjs/x402/types.js.map +1 -1
  60. package/dist/cjs/x402/verify-payment.js +2 -1
  61. package/dist/cjs/x402/verify-payment.js.map +1 -1
  62. package/dist/esm/bridge/Buy.js +2 -2
  63. package/dist/esm/bridge/Chains.js +1 -1
  64. package/dist/esm/bridge/Routes.js +1 -1
  65. package/dist/esm/bridge/Sell.js +2 -2
  66. package/dist/esm/bridge/Status.js +1 -1
  67. package/dist/esm/bridge/Token.js +3 -3
  68. package/dist/esm/bridge/Transfer.js +1 -1
  69. package/dist/esm/bridge/Webhook.js +1 -1
  70. package/dist/esm/exports/react.js +1 -0
  71. package/dist/esm/exports/react.js.map +1 -1
  72. package/dist/esm/exports/thirdweb.js +1 -1
  73. package/dist/esm/react/core/hooks/useStepExecutor.js +1 -21
  74. package/dist/esm/react/core/hooks/useStepExecutor.js.map +1 -1
  75. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js +5 -6
  76. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
  77. package/dist/esm/react/web/ui/Bridge/StepRunner.js +2 -2
  78. package/dist/esm/react/web/ui/Bridge/StepRunner.js.map +1 -1
  79. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js +1 -0
  80. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  81. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js +92 -0
  82. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -0
  83. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js +1 -0
  84. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
  85. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js +13 -1
  86. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  87. package/dist/esm/react/web/ui/Bridge/swap-widget/select-chain.js +13 -2
  88. package/dist/esm/react/web/ui/Bridge/swap-widget/select-chain.js.map +1 -1
  89. package/dist/esm/react/web/ui/Bridge/swap-widget/select-token-ui.js +13 -4
  90. package/dist/esm/react/web/ui/Bridge/swap-widget/select-token-ui.js.map +1 -1
  91. package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js +6 -10
  92. package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +2 -1
  94. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  95. package/dist/esm/script-exports/bridge-widget-script.js +14 -0
  96. package/dist/esm/script-exports/bridge-widget-script.js.map +1 -0
  97. package/dist/esm/script-exports/bridge-widget.js +10 -0
  98. package/dist/esm/script-exports/bridge-widget.js.map +1 -0
  99. package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js +29 -0
  100. package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js.map +1 -1
  101. package/dist/esm/stories/Bridge/BridgeWidget/bridge-widget-script.stories.js +40 -0
  102. package/dist/esm/stories/Bridge/BridgeWidget/bridge-widget-script.stories.js.map +1 -0
  103. package/dist/esm/stories/Bridge/StepRunner.stories.js +2 -22
  104. package/dist/esm/stories/Bridge/StepRunner.stories.js.map +1 -1
  105. package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js +4 -4
  106. package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
  107. package/dist/esm/utils/units.js +3 -0
  108. package/dist/esm/utils/units.js.map +1 -1
  109. package/dist/esm/version.js +1 -1
  110. package/dist/esm/x402/common.js +42 -42
  111. package/dist/esm/x402/common.js.map +1 -1
  112. package/dist/esm/x402/facilitator.js +1 -0
  113. package/dist/esm/x402/facilitator.js.map +1 -1
  114. package/dist/esm/x402/fetchWithPayment.js +1 -1
  115. package/dist/esm/x402/fetchWithPayment.js.map +1 -1
  116. package/dist/esm/x402/schemas.js +3 -0
  117. package/dist/esm/x402/schemas.js.map +1 -1
  118. package/dist/esm/x402/settle-payment.js +4 -3
  119. package/dist/esm/x402/settle-payment.js.map +1 -1
  120. package/dist/esm/x402/types.js.map +1 -1
  121. package/dist/esm/x402/verify-payment.js +2 -1
  122. package/dist/esm/x402/verify-payment.js.map +1 -1
  123. package/dist/scripts/bridge-widget.d.ts +1118 -0
  124. package/dist/scripts/bridge-widget.js +532 -0
  125. package/dist/types/bridge/Buy.d.ts +2 -2
  126. package/dist/types/bridge/Chains.d.ts +1 -1
  127. package/dist/types/bridge/Routes.d.ts +1 -1
  128. package/dist/types/bridge/Sell.d.ts +2 -2
  129. package/dist/types/bridge/Status.d.ts +1 -1
  130. package/dist/types/bridge/Token.d.ts +3 -3
  131. package/dist/types/bridge/Transfer.d.ts +1 -1
  132. package/dist/types/bridge/Webhook.d.ts +1 -1
  133. package/dist/types/bridge/types/Chain.d.ts +1 -1
  134. package/dist/types/exports/react.d.ts +1 -0
  135. package/dist/types/exports/react.d.ts.map +1 -1
  136. package/dist/types/exports/thirdweb.d.ts +1 -1
  137. package/dist/types/react/core/hooks/useStepExecutor.d.ts +3 -4
  138. package/dist/types/react/core/hooks/useStepExecutor.d.ts.map +1 -1
  139. package/dist/types/react/core/hooks/useTransactionDetails.d.ts +1 -1
  140. package/dist/types/react/core/hooks/useTransactionDetails.d.ts.map +1 -1
  141. package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +1 -1
  142. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts +1 -1
  143. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
  144. package/dist/types/react/web/ui/Bridge/StepRunner.d.ts +6 -2
  145. package/dist/types/react/web/ui/Bridge/StepRunner.d.ts.map +1 -1
  146. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
  147. package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts +218 -0
  148. package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts.map +1 -0
  149. package/dist/types/react/web/ui/Bridge/swap-widget/SwapWidget.d.ts.map +1 -1
  150. package/dist/types/react/web/ui/Bridge/swap-widget/select-chain.d.ts.map +1 -1
  151. package/dist/types/react/web/ui/Bridge/swap-widget/select-token-ui.d.ts +1 -1
  152. package/dist/types/react/web/ui/Bridge/swap-widget/select-token-ui.d.ts.map +1 -1
  153. package/dist/types/react/web/ui/Bridge/swap-widget/swap-ui.d.ts.map +1 -1
  154. package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
  155. package/dist/types/script-exports/bridge-widget-script.d.ts +49 -0
  156. package/dist/types/script-exports/bridge-widget-script.d.ts.map +1 -0
  157. package/dist/types/script-exports/bridge-widget.d.ts +4 -0
  158. package/dist/types/script-exports/bridge-widget.d.ts.map +1 -0
  159. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts +4 -0
  160. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +1 -1
  161. package/dist/types/stories/Bridge/BridgeWidget/bridge-widget-script.stories.d.ts +10 -0
  162. package/dist/types/stories/Bridge/BridgeWidget/bridge-widget-script.stories.d.ts.map +1 -0
  163. package/dist/types/stories/Bridge/StepRunner.stories.d.ts +0 -6
  164. package/dist/types/stories/Bridge/StepRunner.stories.d.ts.map +1 -1
  165. package/dist/types/utils/domains.d.ts +1 -1
  166. package/dist/types/utils/units.d.ts.map +1 -1
  167. package/dist/types/version.d.ts +1 -1
  168. package/dist/types/x402/common.d.ts.map +1 -1
  169. package/dist/types/x402/facilitator.d.ts +1 -0
  170. package/dist/types/x402/facilitator.d.ts.map +1 -1
  171. package/dist/types/x402/fetchWithPayment.d.ts.map +1 -1
  172. package/dist/types/x402/schemas.d.ts +2 -1
  173. package/dist/types/x402/schemas.d.ts.map +1 -1
  174. package/dist/types/x402/settle-payment.d.ts +4 -2
  175. package/dist/types/x402/settle-payment.d.ts.map +1 -1
  176. package/dist/types/x402/types.d.ts +2 -1
  177. package/dist/types/x402/types.d.ts.map +1 -1
  178. package/dist/types/x402/verify-payment.d.ts +2 -1
  179. package/dist/types/x402/verify-payment.d.ts.map +1 -1
  180. package/package.json +7 -4
  181. package/src/bridge/Buy.ts +2 -2
  182. package/src/bridge/Chains.ts +1 -1
  183. package/src/bridge/Routes.ts +1 -1
  184. package/src/bridge/Sell.ts +2 -2
  185. package/src/bridge/Status.ts +1 -1
  186. package/src/bridge/Token.ts +3 -3
  187. package/src/bridge/Transfer.ts +1 -1
  188. package/src/bridge/Webhook.ts +1 -1
  189. package/src/bridge/types/Chain.ts +1 -1
  190. package/src/exports/react.ts +4 -0
  191. package/src/exports/thirdweb.ts +1 -1
  192. package/src/react/core/hooks/useStepExecutor.ts +5 -30
  193. package/src/react/core/hooks/useTransactionDetails.ts +1 -1
  194. package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +6 -9
  195. package/src/react/web/ui/Bridge/BuyWidget.tsx +1 -1
  196. package/src/react/web/ui/Bridge/StepRunner.tsx +11 -2
  197. package/src/react/web/ui/Bridge/TransactionPayment.tsx +1 -0
  198. package/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx +344 -0
  199. package/src/react/web/ui/Bridge/payment-details/PaymentOverview.tsx +1 -0
  200. package/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx +14 -0
  201. package/src/react/web/ui/Bridge/swap-widget/select-chain.tsx +17 -2
  202. package/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx +14 -5
  203. package/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx +6 -14
  204. package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +3 -1
  205. package/src/script-exports/bridge-widget-script.tsx +72 -0
  206. package/src/script-exports/bridge-widget.tsx +17 -0
  207. package/src/script-exports/readme.md +72 -0
  208. package/src/stories/Bridge/BridgeOrchestrator.stories.tsx +31 -0
  209. package/src/stories/Bridge/BridgeWidget/bridge-widget-script.stories.tsx +79 -0
  210. package/src/stories/Bridge/StepRunner.stories.tsx +6 -23
  211. package/src/stories/Bridge/UnsupportedTokenScreen.stories.tsx +4 -4
  212. package/src/utils/domains.ts +1 -1
  213. package/src/utils/units.test.ts +13 -0
  214. package/src/utils/units.ts +4 -0
  215. package/src/version.ts +1 -1
  216. package/src/wallets/eip5792/send-calls.ts +1 -1
  217. package/src/wallets/smart/smart-wallet-modular.test.ts +1 -1
  218. package/src/x402/common.ts +46 -52
  219. package/src/x402/facilitator.ts +1 -0
  220. package/src/x402/fetchWithPayment.ts +3 -1
  221. package/src/x402/schemas.ts +5 -1
  222. package/src/x402/settle-payment.ts +4 -3
  223. package/src/x402/types.ts +2 -1
  224. package/src/x402/verify-payment.ts +2 -1
@@ -0,0 +1,1118 @@
1
+ import { Container } from 'react-dom/client';
2
+ import { Address, Hex } from 'ox';
3
+
4
+ declare const currencySymbol: {
5
+ readonly USD: "$";
6
+ readonly EUR: "€";
7
+ readonly GBP: "£";
8
+ readonly JPY: "¥";
9
+ readonly KRW: "₩";
10
+ readonly CNY: "¥";
11
+ readonly INR: "₹";
12
+ readonly NOK: "kr";
13
+ readonly SEK: "kr";
14
+ readonly CHF: "CHF";
15
+ readonly AUD: "$";
16
+ readonly CAD: "$";
17
+ readonly NZD: "$";
18
+ readonly MXN: "$";
19
+ readonly BRL: "R$";
20
+ readonly CLP: "$";
21
+ readonly CZK: "Kč";
22
+ readonly DKK: "kr";
23
+ readonly HKD: "$";
24
+ readonly HUF: "Ft";
25
+ readonly IDR: "Rp";
26
+ readonly ILS: "₪";
27
+ readonly ISK: "kr";
28
+ };
29
+ type SupportedFiatCurrency = keyof typeof currencySymbol;
30
+
31
+ type PurchaseData = Record<string, unknown>;
32
+
33
+ /**
34
+ * @theme
35
+ */
36
+ type Theme = {
37
+ type: "light" | "dark";
38
+ colors: {
39
+ primaryText: string;
40
+ secondaryText: string;
41
+ accentText: string;
42
+ danger: string;
43
+ success: string;
44
+ modalOverlayBg: string;
45
+ accentButtonBg: string;
46
+ accentButtonText: string;
47
+ primaryButtonBg: string;
48
+ primaryButtonText: string;
49
+ secondaryButtonBg: string;
50
+ secondaryButtonText: string;
51
+ secondaryButtonHoverBg: string;
52
+ modalBg: string;
53
+ tooltipBg: string;
54
+ tooltipText: string;
55
+ inputAutofillBg: string;
56
+ scrollbarBg: string;
57
+ tertiaryBg: string;
58
+ separatorLine: string;
59
+ secondaryIconColor: string;
60
+ secondaryIconHoverBg: string;
61
+ secondaryIconHoverColor: string;
62
+ borderColor: string;
63
+ skeletonBg: string;
64
+ selectedTextColor: string;
65
+ selectedTextBg: string;
66
+ connectedButtonBg: string;
67
+ connectedButtonBgHover: string;
68
+ };
69
+ fontFamily: string;
70
+ };
71
+ /**
72
+ * @theme
73
+ */
74
+ type ThemeOverrides = {
75
+ [key in Exclude<keyof Theme, "type">]?: Partial<Theme[key]>;
76
+ };
77
+
78
+ /**
79
+ * Combines members of an intersection into a readable type.
80
+ * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
81
+ * @example
82
+ * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
83
+ * => { a: string, b: string, c: number, d: bigint }
84
+ */
85
+ type Prettify<T> = {
86
+ [K in keyof T]: T[K];
87
+ } & {};
88
+
89
+ type FetchConfig = {
90
+ requestTimeoutMs?: number;
91
+ keepalive?: boolean;
92
+ headers?: HeadersInit;
93
+ };
94
+ type ClientOptions = Prettify<{
95
+ /**
96
+ * The configuration options for the client.
97
+ */
98
+ config?: {
99
+ /**
100
+ * The configuration options for the RPC client.
101
+ */
102
+ rpc?: {
103
+ /**
104
+ * The configuration options for the fetch function.
105
+ * @default {}
106
+ */
107
+ fetch?: FetchConfig;
108
+ /**
109
+ * The maximum number of requests to batch together.
110
+ * @default 100
111
+ */
112
+ maxBatchSize?: number;
113
+ /**
114
+ * The maximum time to wait before sending a batch of requests.
115
+ * @default 0 (no timeout)
116
+ */
117
+ batchTimeoutMs?: number;
118
+ };
119
+ /**
120
+ * The configuration options for the storage client.
121
+ */
122
+ storage?: {
123
+ /**
124
+ * The configuration options for the fetch function.
125
+ * @default {}
126
+ */
127
+ fetch?: FetchConfig;
128
+ /**
129
+ * The IPFS gateway URL.
130
+ * @default "https://<your_client_id>.ipfscdn.io/ipfs/<cid>"
131
+ */
132
+ gatewayUrl?: string;
133
+ };
134
+ };
135
+ /**
136
+ * The team ID for thirdweb dashboard usage.
137
+ * @hidden
138
+ */
139
+ teamId?: string;
140
+ }>;
141
+ type ThirdwebClient = {
142
+ readonly clientId: string;
143
+ readonly secretKey: string | undefined;
144
+ } & Readonly<ClientOptions>;
145
+
146
+ type FeeType = "legacy" | "eip1559";
147
+
148
+ /**
149
+ * @chain
150
+ */
151
+ type Chain = Readonly<ChainOptions & {
152
+ rpc: string;
153
+ }>;
154
+ /**
155
+ * @chain
156
+ */
157
+ type ChainOptions = {
158
+ id: number;
159
+ name?: string;
160
+ rpc?: string;
161
+ icon?: Icon;
162
+ nativeCurrency?: {
163
+ name?: string;
164
+ symbol?: string;
165
+ decimals?: number;
166
+ };
167
+ blockExplorers?: Array<{
168
+ name: string;
169
+ url: string;
170
+ apiUrl?: string;
171
+ }>;
172
+ testnet?: true;
173
+ experimental?: {
174
+ increaseZeroByteCount?: boolean;
175
+ };
176
+ faucets?: Array<string>;
177
+ feeType?: FeeType;
178
+ };
179
+ /**
180
+ * @chain
181
+ */
182
+ type Icon = {
183
+ url: string;
184
+ width: number;
185
+ height: number;
186
+ format: string;
187
+ };
188
+
189
+ type Action = "approval" | "transfer" | "buy" | "sell" | "fee";
190
+
191
+ type Token = {
192
+ chainId: number;
193
+ address: Address.Address;
194
+ decimals: number;
195
+ symbol: string;
196
+ name: string;
197
+ iconUri?: string;
198
+ marketCapUsd?: number;
199
+ volume24hUsd?: number;
200
+ };
201
+ type TokenWithPrices = Token & {
202
+ prices: Record<string, number>;
203
+ };
204
+
205
+ type RouteStep = {
206
+ originToken: TokenWithPrices;
207
+ destinationToken: TokenWithPrices;
208
+ originAmount: bigint;
209
+ destinationAmount: bigint;
210
+ estimatedExecutionTimeMs: number;
211
+ transactions: RouteTransaction[];
212
+ };
213
+ type RouteTransaction = {
214
+ data: Hex.Hex;
215
+ to: Hex.Hex;
216
+ value?: bigint | undefined;
217
+ chainId: number;
218
+ /**
219
+ * The action this transaction performs. This can be "approval", "transfer", "buy", or "sell".
220
+ */
221
+ action: Action;
222
+ /**
223
+ * The transaction ID, used for tracking purposes.
224
+ */
225
+ id: Hex.Hex;
226
+ client: ThirdwebClient;
227
+ chain: Chain;
228
+ };
229
+
230
+ type PreparedQuote = {
231
+ /**
232
+ * The input amount (in wei) including fees to be paid.
233
+ */
234
+ originAmount: bigint;
235
+ /**
236
+ * The output amount (in wei) to be received.
237
+ */
238
+ destinationAmount: bigint;
239
+ /**
240
+ * The blocknumber this quote was generated at.
241
+ */
242
+ blockNumber?: bigint;
243
+ /**
244
+ * The timestamp this quote was generated at.
245
+ */
246
+ timestamp: number;
247
+ /**
248
+ * The estimated execution time in milliseconds.
249
+ */
250
+ estimatedExecutionTimeMs?: number | undefined;
251
+ /**
252
+ * The expiration timestamp for the quote. All transactions must be executed before this timestamp to guarantee successful execution at the specified price.
253
+ */
254
+ expiration?: number | undefined;
255
+ /**
256
+ * A series of steps required to complete the quote, along with the transactions to execute in order.
257
+ */
258
+ steps: RouteStep[];
259
+ };
260
+
261
+ /**
262
+ * Prepares a **finalized** Bridge quote for the provided buy request with transaction data. This function will return everything `quote` does, with the addition of a series of prepared transactions and the associated expiration timestamp.
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
267
+ *
268
+ * const quote = await Bridge.Buy.prepare({
269
+ * originChainId: 1,
270
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
271
+ * destinationChainId: 10,
272
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
273
+ * amount: toWei("0.01"),
274
+ * sender: "0x...",
275
+ * receiver: "0x...",
276
+ * client: thirdwebClient,
277
+ * });
278
+ * ```
279
+ *
280
+ * This will return a quote that might look like:
281
+ * ```typescript
282
+ * {
283
+ * originAmount: 2000030000n,
284
+ * destinationAmount: 1000000000000000000n,
285
+ * blockNumber: 22026509n,
286
+ * timestamp: 1741730936680,
287
+ * estimatedExecutionTimeMs: 1000
288
+ * steps: [
289
+ * {
290
+ * originToken: {
291
+ * chainId: 1,
292
+ * address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
293
+ * symbol: "USDC",
294
+ * name: "USDC",
295
+ * decimals: 6,
296
+ * priceUsd: 1,
297
+ * iconUri: "https://..."
298
+ * },
299
+ * destinationToken: {
300
+ * chainId: 10,
301
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
302
+ * symbol: "ETH",
303
+ * name: "Ethereum",
304
+ * decimals: 18,
305
+ * priceUsd: 2000,
306
+ * iconUri: "https://..."
307
+ * },
308
+ * originAmount: 2000030000n,
309
+ * destinationAmount: 1000000000000000000n,
310
+ * estimatedExecutionTimeMs: 1000
311
+ * transactions: [
312
+ * {
313
+ * action: "approval",
314
+ * id: "0x",
315
+ * to: "0x...",
316
+ * data: "0x...",
317
+ * chainId: 10,
318
+ * type: "eip1559"
319
+ * },
320
+ * {
321
+ * action: "buy",
322
+ * to: "0x...",
323
+ * value: 10000026098875381n,
324
+ * data: "0x...",
325
+ * chainId: 10,
326
+ * type: "eip1559"
327
+ * }
328
+ * ]
329
+ * }
330
+ * ],
331
+ * expiration: 1741730936680,
332
+ * intent: {
333
+ * originChainId: 1,
334
+ * originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
335
+ * destinationChainId: 10,
336
+ * destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
337
+ * amount: 1000000000000000000n
338
+ * }
339
+ * }
340
+ * ```
341
+ *
342
+ * ## Sending the transactions
343
+ * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
344
+ * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
345
+ * - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
346
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
347
+ *
348
+ * NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
349
+ *
350
+ * You can access this functions input and output types with `Buy.prepare.Options` and `Buy.prepare.Result`, respectively.
351
+ *
352
+ * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
353
+ *
354
+ * ```ts
355
+ * const quote = await Bridge.Buy.prepare({
356
+ * originChainId: 1,
357
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
358
+ * destinationChainId: 10,
359
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
360
+ * amount: toWei("0.01"),
361
+ * sender: "0x...",
362
+ * receiver: "0x...",
363
+ * purchaseData: {
364
+ * size: "large",
365
+ * shippingAddress: "123 Main St, New York, NY 10001",
366
+ * },
367
+ * client: thirdwebClient,
368
+ * });
369
+ * ```
370
+ *
371
+ * To limit quotes to routes that have a certain number of steps involved, use the `maxSteps` option.
372
+ *
373
+ * ```ts
374
+ * const quote = await Bridge.Buy.prepare({
375
+ * originChainId: 1,
376
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
377
+ * destinationChainId: 10,
378
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
379
+ * amount: toWei("0.01"),
380
+ * sender: "0x...",
381
+ * receiver: "0x...",
382
+ * maxSteps: 2, // Will only return a quote for routes with 2 or fewer steps
383
+ * client: thirdwebClient,
384
+ * });
385
+ * ```
386
+ *
387
+ * @param options - The options for the quote.
388
+ * @param options.originChainId - The chain ID of the origin token.
389
+ * @param options.originTokenAddress - The address of the origin token.
390
+ * @param options.destinationChainId - The chain ID of the destination token.
391
+ * @param options.destinationTokenAddress - The address of the destination token.
392
+ * @param options.amount - The amount of the destination token to receive.
393
+ * @param options.sender - The address of the sender.
394
+ * @param options.receiver - The address of the recipient.
395
+ * @param [options.purchaseData] - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls.
396
+ * @param [options.maxSteps] - Limit the number of total steps in the route.
397
+ * @param options.client - Your thirdweb client.
398
+ *
399
+ * @returns A promise that resolves to a finalized quote and transactions for the requested buy.
400
+ *
401
+ * @throws Will throw an error if there is an issue fetching the quote.
402
+ * @bridge Buy
403
+ */
404
+ declare function prepare$3(options: prepare$3.Options): Promise<prepare$3.Result>;
405
+ /**
406
+ * Namespace containing types for the buy prepare function.
407
+ * @namespace prepare
408
+ * @bridge Buy
409
+ */
410
+ declare namespace prepare$3 {
411
+ /**
412
+ * Options for preparing a buy transaction.
413
+ * @interface Options
414
+ * @bridge Buy
415
+ */
416
+ type Options = {
417
+ /** The origin chain ID */
418
+ originChainId: number;
419
+ /** The origin token address */
420
+ originTokenAddress: Address.Address;
421
+ /** The destination chain ID */
422
+ destinationChainId: number;
423
+ /** The destination token address */
424
+ destinationTokenAddress: Address.Address;
425
+ /** The sender address */
426
+ sender: Address.Address;
427
+ /** The receiver address */
428
+ receiver: Address.Address;
429
+ /** The amount to buy in wei */
430
+ amount: bigint;
431
+ /** Your thirdweb client */
432
+ client: ThirdwebClient;
433
+ /** Arbitrary purchase data */
434
+ purchaseData?: PurchaseData;
435
+ /** Maximum number of steps in the route */
436
+ maxSteps?: number;
437
+ /**
438
+ * @hidden
439
+ */
440
+ paymentLinkId?: string;
441
+ };
442
+ /**
443
+ * Result returned from preparing a buy transaction.
444
+ * Contains prepared quote with transaction data and intent information.
445
+ * @interface Result
446
+ * @bridge Buy
447
+ */
448
+ type Result = PreparedQuote & {
449
+ intent: {
450
+ originChainId: number;
451
+ originTokenAddress: Address.Address;
452
+ destinationChainId: number;
453
+ destinationTokenAddress: Address.Address;
454
+ amount: bigint;
455
+ sender: Address.Address;
456
+ receiver: Address.Address;
457
+ purchaseData?: PurchaseData;
458
+ };
459
+ };
460
+ }
461
+
462
+ type OnrampIntent = {
463
+ onramp: "stripe" | "coinbase" | "transak";
464
+ chainId: number;
465
+ tokenAddress: Address.Address;
466
+ receiver: Address.Address;
467
+ amount?: string;
468
+ purchaseData?: PurchaseData;
469
+ sender?: Address.Address;
470
+ onrampTokenAddress?: Address.Address;
471
+ onrampChainId?: number;
472
+ currency?: string;
473
+ maxSteps?: number;
474
+ excludeChainIds?: string | string[];
475
+ };
476
+ type OnrampPrepareQuoteResponseData = {
477
+ id: string;
478
+ link: string;
479
+ currency: string;
480
+ currencyAmount: number;
481
+ destinationAmount: bigint;
482
+ destinationToken: TokenWithPrices;
483
+ timestamp?: number;
484
+ expiration?: number;
485
+ steps: RouteStep[];
486
+ intent: OnrampIntent;
487
+ };
488
+ /**
489
+ * Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * import { Bridge } from "thirdweb";
494
+ * import { ethereum } from "thirdweb/chains";
495
+ * import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils";
496
+ *
497
+ * const preparedOnramp = await Bridge.Onramp.prepare({
498
+ * client: thirdwebClient,
499
+ * onramp: "stripe",
500
+ * chainId: ethereum.id,
501
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
502
+ * receiver: "0x...", // receiver's address
503
+ * amount: toWei("10"), // 10 of the destination token
504
+ * // Optional params:
505
+ * // sender: "0x...", // sender's address
506
+ * // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to
507
+ * // onrampChainId: 1, // chain to initially onramp to
508
+ * // currency: "USD",
509
+ * // maxSteps: 2,
510
+ * // purchaseData: { customId: "123" }
511
+ * });
512
+ *
513
+ * console.log(preparedOnramp.link); // URL to redirect the user to
514
+ * console.log(preparedOnramp.currencyAmount); // Amount in fiat the user will pay
515
+ * ```
516
+ *
517
+ * This function returns a quote that might look like:
518
+ * ```typescript
519
+ * {
520
+ * id: "123e4567-e89b-12d3-a456-426614174000",
521
+ * link: "https://onramp.example.com/session?id=...",
522
+ * currency: "USD",
523
+ * currencyAmount: 10.52,
524
+ * destinationAmount: 10000000000000000000n, // 10 ETH if decimals 18
525
+ * timestamp: 1689812800,
526
+ * expiration: 1689842800,
527
+ * steps: [
528
+ * // ... further steps if any post-onramp swaps are needed
529
+ * ],
530
+ * intent: {
531
+ * onramp: "stripe",
532
+ * chainId: 1,
533
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
534
+ * receiver: "0x...",
535
+ * amount: "10000000000000000000"
536
+ * }
537
+ * }
538
+ * ```
539
+ *
540
+ * ### Global Support
541
+ *
542
+ * For the best user experience, specify the user's `country` code in your request. This will return an error if the user's country is not supported by the provider.
543
+ *
544
+ * ```typescript
545
+ * const preparedOnramp = await Bridge.Onramp.prepare({
546
+ * client: thirdwebClient,
547
+ * onramp: "stripe",
548
+ * chainId: ethereum.id,
549
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
550
+ * receiver: "0x...", // receiver's address
551
+ * amount: toWei("10"), // 10 of the destination token
552
+ * country: "AU" // User's country code
553
+ * });
554
+ * ```
555
+ *
556
+ * @param options - The options for preparing the onramp.
557
+ * @param options.client - Your thirdweb client.
558
+ * @param options.onramp - The onramp provider to use (e.g., "stripe", "coinbase", "transak").
559
+ * @param options.chainId - The destination chain ID.
560
+ * @param options.tokenAddress - The destination token address.
561
+ * @param options.receiver - The address that will receive the output token.
562
+ * @param [options.amount] - The desired token amount in wei.
563
+ * @param [options.purchaseData] - Arbitrary purchase data.
564
+ * @param [options.sender] - An optional address to associate as the onramp sender.
565
+ * @param [options.onrampTokenAddress] - The token to initially onramp to if the destination token is not supported by the provider.
566
+ * @param [options.onrampChainId] - The chain ID to initially onramp to if the destination chain is not supported.
567
+ * @param [options.currency] - The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD".
568
+ * @param [options.maxSteps] - Maximum number of post-onramp steps.
569
+ * @param [options.excludeChainIds] - Chain IDs to exclude from the route (string or array of strings).
570
+ * @param [options.country] - The user's country code (e.g. "US", "JP"). Defaults to "US". We highly recommend this be set (based on the user's IP address).
571
+ *
572
+ * @returns A promise that resolves to the prepared onramp details, including the link and quote.
573
+ * @throws Will throw an error if there is an issue preparing the onramp.
574
+ * @bridge Onramp
575
+ * @beta
576
+ */
577
+ declare function prepare$2(options: prepare$2.Options): Promise<prepare$2.Result>;
578
+ /**
579
+ * Namespace containing types for the onramp prepare function.
580
+ * @namespace prepare
581
+ * @bridge Onramp
582
+ */
583
+ declare namespace prepare$2 {
584
+ /**
585
+ * Options for preparing an onramp transaction.
586
+ * @interface Options
587
+ * @bridge Onramp
588
+ */
589
+ type Options = {
590
+ /** Your thirdweb client */
591
+ client: ThirdwebClient;
592
+ /** The onramp provider to use (e.g., "stripe", "coinbase", "transak") */
593
+ onramp: "stripe" | "coinbase" | "transak";
594
+ /** The destination chain ID */
595
+ chainId: number;
596
+ /** The destination token address */
597
+ tokenAddress: Address.Address;
598
+ /** The address that will receive the output token */
599
+ receiver: Address.Address;
600
+ /** The desired token amount in wei */
601
+ amount?: bigint;
602
+ /** Arbitrary purchase data */
603
+ purchaseData?: PurchaseData;
604
+ /** An optional address to associate as the onramp sender */
605
+ sender?: Address.Address;
606
+ /** The token to initially onramp to if the destination token is not supported by the provider */
607
+ onrampTokenAddress?: Address.Address;
608
+ /** The chain ID to initially onramp to if the destination chain is not supported */
609
+ onrampChainId?: number;
610
+ /** The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD" */
611
+ currency?: string;
612
+ /** Maximum number of post-onramp steps */
613
+ maxSteps?: number;
614
+ /** Chain IDs to exclude from the route (string or array of strings) */
615
+ excludeChainIds?: string | string[];
616
+ /** The user's country code (e.g. "US", "JP"). Defaults to "US". We highly recommend this be set (based on the user's IP address) */
617
+ country?: string;
618
+ /**
619
+ * @hidden
620
+ */
621
+ paymentLinkId?: string;
622
+ };
623
+ /**
624
+ * Result returned from preparing an onramp transaction.
625
+ * Contains the onramp link, quote information, and routing steps.
626
+ * @interface Result
627
+ * @bridge Onramp
628
+ */
629
+ type Result = OnrampPrepareQuoteResponseData;
630
+ }
631
+
632
+ /**
633
+ * Prepares a **finalized** Bridge quote for the provided sell request with transaction data. This function will return everything `quote` does, with the addition of a series of prepared transactions and the associated expiration timestamp.
634
+ *
635
+ * @example
636
+ * ```typescript
637
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
638
+ *
639
+ * const quote = await Bridge.Sell.prepare({
640
+ * originChainId: 1,
641
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
642
+ * destinationChainId: 10,
643
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
644
+ * amount: toWei("0.01"),
645
+ * client: thirdwebClient,
646
+ * });
647
+ * ```
648
+ *
649
+ * This will return a quote that might look like:
650
+ * ```typescript
651
+ * {
652
+ * originAmount: 2000000000n,
653
+ * destinationAmount: 9980000000000000000n,
654
+ * blockNumber: 22026509n,
655
+ * timestamp: 1741730936680,
656
+ * estimatedExecutionTimeMs: 1000
657
+ * steps: [
658
+ * {
659
+ * originToken: {
660
+ * chainId: 1,
661
+ * address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
662
+ * symbol: "USDC",
663
+ * name: "USDC",
664
+ * decimals: 6,
665
+ * priceUsd: 1,
666
+ * iconUri: "https://..."
667
+ * },
668
+ * destinationToken: {
669
+ * chainId: 10,
670
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
671
+ * symbol: "ETH",
672
+ * name: "Ethereum",
673
+ * decimals: 18,
674
+ * priceUsd: 2000,
675
+ * iconUri: "https://..."
676
+ * },
677
+ * originAmount: 2000000000n,
678
+ * destinationAmount: 9980000000000000000n,
679
+ * estimatedExecutionTimeMs: 1000
680
+ * }
681
+ * transactions: [
682
+ * {
683
+ * id: "0x...",
684
+ * action: "approval",
685
+ * to: "0x...",
686
+ * data: "0x...",
687
+ * chainId: 10,
688
+ * type: "eip1559"
689
+ * },
690
+ * {
691
+ * id: "0x...",
692
+ * action: "sell",
693
+ * to: "0x...",
694
+ * data: "0x...",
695
+ * chainId: 10,
696
+ * type: "eip1559"
697
+ * }
698
+ * ],
699
+ * ],
700
+ * expiration: 1741730936680,
701
+ * intent: {
702
+ * originChainId: 1,
703
+ * originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
704
+ * destinationChainId: 10,
705
+ * destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
706
+ * amount: 2000000000n
707
+ * }
708
+ * }
709
+ * ```
710
+ *
711
+ * ## Sending the transactions
712
+ * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
713
+ * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
714
+ * - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
715
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
716
+ *
717
+ * NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
718
+ *
719
+ * You can access this functions input and output types with `Sell.prepare.Options` and `Sell.prepare.Result`, respectively.
720
+ *
721
+ * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
722
+ *
723
+ * ```ts
724
+ * const quote = await Bridge.Sell.prepare({
725
+ * originChainId: 1,
726
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
727
+ * destinationChainId: 10,
728
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
729
+ * amount: toWei("0.01"),
730
+ * purchaseData: {
731
+ * size: "large",
732
+ * shippingAddress: "123 Main St, New York, NY 10001",
733
+ * },
734
+ * client: thirdwebClient,
735
+ * });
736
+ * ```
737
+ *
738
+ * To limit quotes to routes that have a certain number of steps involved, use the `maxSteps` option.
739
+ *
740
+ * ```ts
741
+ * const quote = await Bridge.Sell.prepare({
742
+ * originChainId: 1,
743
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
744
+ * destinationChainId: 10,
745
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
746
+ * amount: toWei("0.01"),
747
+ * maxSteps: 2, // Will only return a quote for routes with 2 or fewer steps
748
+ * client: thirdwebClient,
749
+ * });
750
+ * ```
751
+ *
752
+ * @param options - The options for the quote.
753
+ * @param options.originChainId - The chain ID of the origin token.
754
+ * @param options.originTokenAddress - The address of the origin token.
755
+ * @param options.destinationChainId - The chain ID of the destination token.
756
+ * @param options.destinationTokenAddress - The address of the destination token.
757
+ * @param options.amount - The amount of the origin token to sell.
758
+ * @param options.sender - The address of the sender.
759
+ * @param options.receiver - The address of the recipient.
760
+ * @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls.
761
+ * @param [options.maxSteps] - Limit the number of total steps in the route.
762
+ * @param options.client - Your thirdweb client.
763
+ *
764
+ * @returns A promise that resolves to a finalized quote and transactions for the requested sell.
765
+ *
766
+ * @throws Will throw an error if there is an issue fetching the quote.
767
+ * @bridge Sell
768
+ * @beta
769
+ */
770
+ declare function prepare$1(options: prepare$1.Options): Promise<prepare$1.Result>;
771
+ /**
772
+ * Namespace containing types for the sell prepare function.
773
+ * @namespace prepare
774
+ * @bridge Sell
775
+ */
776
+ declare namespace prepare$1 {
777
+ /**
778
+ * Options for preparing a sell transaction.
779
+ * @interface Options
780
+ * @bridge Sell
781
+ */
782
+ type Options = {
783
+ /** The origin chain ID */
784
+ originChainId: number;
785
+ /** The origin token address */
786
+ originTokenAddress: Address.Address;
787
+ /** The destination chain ID */
788
+ destinationChainId: number;
789
+ /** The destination token address */
790
+ destinationTokenAddress: Address.Address;
791
+ /** The amount to sell in wei */
792
+ amount: bigint;
793
+ /** The sender address */
794
+ sender: Address.Address;
795
+ /** The receiver address */
796
+ receiver: Address.Address;
797
+ /** Your thirdweb client */
798
+ client: ThirdwebClient;
799
+ /** Arbitrary purchase data */
800
+ purchaseData?: PurchaseData;
801
+ /** Maximum number of steps in the route */
802
+ maxSteps?: number;
803
+ /**
804
+ * @hidden
805
+ */
806
+ paymentLinkId?: string;
807
+ };
808
+ /**
809
+ * Result returned from preparing a sell transaction.
810
+ * Contains prepared quote with transaction data and intent information.
811
+ * @interface Result
812
+ * @bridge Sell
813
+ */
814
+ type Result = PreparedQuote & {
815
+ intent: {
816
+ originChainId: number;
817
+ originTokenAddress: Address.Address;
818
+ destinationChainId: number;
819
+ destinationTokenAddress: Address.Address;
820
+ amount: bigint;
821
+ sender: Address.Address;
822
+ receiver: Address.Address;
823
+ purchaseData?: PurchaseData;
824
+ };
825
+ };
826
+ }
827
+
828
+ /**
829
+ * Prepares a **finalized** Bridge quote for the provided transfer request with transaction data.
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
834
+ *
835
+ * const quote = await Bridge.Transfer.prepare({
836
+ * chainId: 1,
837
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
838
+ * amount: toWei("0.01"),
839
+ * sender: "0x...",
840
+ * receiver: "0x...",
841
+ * client: thirdwebClient,
842
+ * });
843
+ * ```
844
+ *
845
+ * This will return a quote that might look like:
846
+ * ```typescript
847
+ * {
848
+ * originAmount: 10000026098875381n,
849
+ * destinationAmount: 10000000000000000n,
850
+ * blockNumber: 22026509n,
851
+ * timestamp: 1741730936680,
852
+ * estimatedExecutionTimeMs: 1000
853
+ * steps: [
854
+ * {
855
+ * originToken: {
856
+ * chainId: 1,
857
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
858
+ * symbol: "ETH",
859
+ * name: "Ethereum",
860
+ * decimals: 18,
861
+ * priceUsd: 2000,
862
+ * iconUri: "https://..."
863
+ * },
864
+ * destinationToken: {
865
+ * chainId: 1,
866
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
867
+ * symbol: "ETH",
868
+ * name: "Ethereum",
869
+ * decimals: 18,
870
+ * priceUsd: 2000,
871
+ * iconUri: "https://..."
872
+ * },
873
+ * originAmount: 10000026098875381n,
874
+ * destinationAmount: 10000000000000000n,
875
+ * estimatedExecutionTimeMs: 1000
876
+ * transactions: [
877
+ * {
878
+ * action: "approval",
879
+ * id: "0x",
880
+ * to: "0x...",
881
+ * data: "0x...",
882
+ * chainId: 1,
883
+ * type: "eip1559"
884
+ * },
885
+ * {
886
+ * action: "transfer",
887
+ * to: "0x...",
888
+ * value: 10000026098875381n,
889
+ * data: "0x...",
890
+ * chainId: 1,
891
+ * type: "eip1559"
892
+ * }
893
+ * ]
894
+ * }
895
+ * ],
896
+ * expiration: 1741730936680,
897
+ * intent: {
898
+ * chainId: 1,
899
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
900
+ * amount: 10000000000000000n,
901
+ * sender: "0x...",
902
+ * receiver: "0x..."
903
+ * }
904
+ * }
905
+ * ```
906
+ *
907
+ * ## Sending the transactions
908
+ * The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
909
+ * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
910
+ * - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
911
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
912
+ *
913
+ * NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer.
914
+ *
915
+ * You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
916
+ *
917
+ * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
918
+ *
919
+ * ```ts
920
+ * const quote = await Bridge.Transfer.prepare({
921
+ * chainId: 1,
922
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
923
+ * amount: toWei("0.01"),
924
+ * sender: "0x...",
925
+ * receiver: "0x...",
926
+ * purchaseData: {
927
+ * reference: "payment-123",
928
+ * metadata: {
929
+ * note: "Transfer to Alice"
930
+ * }
931
+ * },
932
+ * client: thirdwebClient,
933
+ * });
934
+ * ```
935
+ *
936
+ * ## Fees
937
+ * There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount.
938
+ *
939
+ * For example, if you were to request a transfer with `feePayer` set to `receiver`:
940
+ * ```typescript
941
+ * const quote = await Bridge.Transfer.prepare({
942
+ * chainId: 1,
943
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
944
+ * amount: 100_000_000n, // 100 USDC
945
+ * sender: "0x...",
946
+ * receiver: "0x...",
947
+ * feePayer: "receiver",
948
+ * client: thirdwebClient,
949
+ * });
950
+ * ```
951
+ *
952
+ * The returned quote might look like:
953
+ * ```typescript
954
+ * {
955
+ * originAmount: 100_000_000n, // 100 USDC
956
+ * destinationAmount: 99_970_000n, // 99.97 USDC
957
+ * ...
958
+ * }
959
+ * ```
960
+ *
961
+ * If you were to request a transfer with `feePayer` set to `sender`:
962
+ * ```typescript
963
+ * const quote = await Bridge.Transfer.prepare({
964
+ * chainId: 1,
965
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
966
+ * amount: 100_000_000n, // 100 USDC
967
+ * sender: "0x...",
968
+ * receiver: "0x...",
969
+ * feePayer: "sender",
970
+ * client: thirdwebClient,
971
+ * });
972
+ * ```
973
+ *
974
+ * The returned quote might look like:
975
+ * ```typescript
976
+ * {
977
+ * originAmount: 100_030_000n, // 100.03 USDC
978
+ * destinationAmount: 100_000_000n, // 100 USDC
979
+ * ...
980
+ * }
981
+ * ```
982
+ *
983
+ * @param options - The options for the quote.
984
+ * @param options.chainId - The chain ID of the token.
985
+ * @param options.tokenAddress - The address of the token.
986
+ * @param options.amount - The amount of the token to transfer.
987
+ * @param options.sender - The address of the sender.
988
+ * @param options.receiver - The address of the recipient.
989
+ * @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
990
+ * @param options.client - Your thirdweb client.
991
+ * @param [options.feePayer] - The address that will pay the fees for the transfer. If not specified, the sender will be used. Values can be "sender" or "receiver".
992
+ *
993
+ * @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
994
+ *
995
+ * @throws Will throw an error if there is an issue fetching the quote.
996
+ * @bridge Transfer
997
+ * @beta
998
+ */
999
+ declare function prepare(options: prepare.Options): Promise<prepare.Result>;
1000
+ /**
1001
+ * Namespace containing types for the transfer prepare function.
1002
+ * @namespace prepare
1003
+ * @bridge Transfer
1004
+ */
1005
+ declare namespace prepare {
1006
+ /**
1007
+ * Options for preparing a transfer transaction.
1008
+ * @interface Options
1009
+ * @bridge Transfer
1010
+ */
1011
+ type Options = {
1012
+ /** The chain ID */
1013
+ chainId: number;
1014
+ /** The token address */
1015
+ tokenAddress: Address.Address;
1016
+ /** The sender address */
1017
+ sender: Address.Address;
1018
+ /** The receiver address */
1019
+ receiver: Address.Address;
1020
+ /** The amount to transfer in wei */
1021
+ amount: bigint;
1022
+ /** Your thirdweb client */
1023
+ client: ThirdwebClient;
1024
+ /** Arbitrary purchase data */
1025
+ purchaseData?: PurchaseData;
1026
+ /** Who pays the fees - sender or receiver */
1027
+ feePayer?: "sender" | "receiver";
1028
+ /**
1029
+ * @hidden
1030
+ */
1031
+ paymentLinkId?: string;
1032
+ };
1033
+ /**
1034
+ * Result returned from preparing a transfer transaction.
1035
+ * Contains prepared quote with transaction data and intent information.
1036
+ * @interface Result
1037
+ * @bridge Transfer
1038
+ */
1039
+ type Result = PreparedQuote & {
1040
+ intent: {
1041
+ chainId: number;
1042
+ tokenAddress: Address.Address;
1043
+ amount: bigint;
1044
+ sender: Address.Address;
1045
+ receiver: Address.Address;
1046
+ purchaseData?: PurchaseData;
1047
+ feePayer?: "sender" | "receiver";
1048
+ };
1049
+ };
1050
+ }
1051
+
1052
+ /**
1053
+ * Union type for different Bridge prepare result types
1054
+ */
1055
+ type BridgePrepareResult = ({
1056
+ type: "buy";
1057
+ } & prepare$3.Result) | ({
1058
+ type: "sell";
1059
+ } & prepare$1.Result) | ({
1060
+ type: "transfer";
1061
+ } & prepare.Result) | ({
1062
+ type: "onramp";
1063
+ } & prepare$2.Result);
1064
+
1065
+ type BuyOrOnrampPrepareResult = Extract<BridgePrepareResult, {
1066
+ type: "buy" | "onramp";
1067
+ }>;
1068
+
1069
+ type SwapPreparedQuote = Extract<BridgePrepareResult, {
1070
+ type: "buy" | "sell";
1071
+ }>;
1072
+
1073
+ type BridgeWidgetScriptProps = {
1074
+ clientId: string;
1075
+ theme?: "light" | "dark" | ({
1076
+ type: "light" | "dark";
1077
+ } & ThemeOverrides);
1078
+ showThirdwebBranding?: boolean;
1079
+ currency?: SupportedFiatCurrency;
1080
+ swap?: {
1081
+ className?: string;
1082
+ style?: React.CSSProperties;
1083
+ onSuccess?: (quote: SwapPreparedQuote) => void;
1084
+ onError?: (error: Error, quote: SwapPreparedQuote) => void;
1085
+ onCancel?: (quote: SwapPreparedQuote) => void;
1086
+ onDisconnect?: () => void;
1087
+ persistTokenSelections?: boolean;
1088
+ prefill?: {
1089
+ buyToken?: {
1090
+ tokenAddress?: string;
1091
+ chainId: number;
1092
+ amount?: string;
1093
+ };
1094
+ sellToken?: {
1095
+ tokenAddress?: string;
1096
+ chainId: number;
1097
+ amount?: string;
1098
+ };
1099
+ };
1100
+ };
1101
+ buy: {
1102
+ amount: string;
1103
+ chainId: number;
1104
+ tokenAddress?: string;
1105
+ buttonLabel?: string;
1106
+ onCancel?: (quote: BuyOrOnrampPrepareResult | undefined) => void;
1107
+ onError?: (error: Error, quote: BuyOrOnrampPrepareResult | undefined) => void;
1108
+ onSuccess?: (quote: BuyOrOnrampPrepareResult) => void;
1109
+ className?: string;
1110
+ country?: string;
1111
+ presetOptions?: [number, number, number];
1112
+ purchaseData?: PurchaseData;
1113
+ };
1114
+ };
1115
+
1116
+ declare function render(element: Container, props: BridgeWidgetScriptProps): void;
1117
+
1118
+ export { render };