thirdweb 5.99.2 → 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414

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 (201) hide show
  1. package/dist/cjs/bridge/Buy.js +16 -12
  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/Routes.js +2 -2
  6. package/dist/cjs/bridge/Routes.js.map +1 -1
  7. package/dist/cjs/bridge/Sell.js +17 -13
  8. package/dist/cjs/bridge/Sell.js.map +1 -1
  9. package/dist/cjs/bridge/Status.js +15 -2
  10. package/dist/cjs/bridge/Status.js.map +1 -1
  11. package/dist/cjs/bridge/Transfer.js +229 -0
  12. package/dist/cjs/bridge/Transfer.js.map +1 -0
  13. package/dist/cjs/bridge/index.js +2 -1
  14. package/dist/cjs/bridge/index.js.map +1 -1
  15. package/dist/cjs/bridge/types/Token.js +3 -0
  16. package/dist/cjs/bridge/types/Token.js.map +1 -0
  17. package/dist/cjs/exports/wallets.js +3 -1
  18. package/dist/cjs/exports/wallets.js.map +1 -1
  19. package/dist/cjs/pay/buyWithCrypto/getQuote.js +159 -53
  20. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  21. package/dist/cjs/pay/buyWithCrypto/getStatus.js +160 -14
  22. package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
  23. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -37
  24. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
  25. package/dist/cjs/pay/utils/definitions.js +1 -31
  26. package/dist/cjs/pay/utils/definitions.js.map +1 -1
  27. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +23 -21
  28. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
  30. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -135
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +4 -4
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +83 -34
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  43. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
  44. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  45. package/dist/cjs/utils/any-evm/zksync/constants.js +1 -0
  46. package/dist/cjs/utils/any-evm/zksync/constants.js.map +1 -1
  47. package/dist/cjs/utils/domains.js +3 -0
  48. package/dist/cjs/utils/domains.js.map +1 -1
  49. package/dist/cjs/version.js +1 -1
  50. package/dist/cjs/version.js.map +1 -1
  51. package/dist/cjs/wallets/injected/mipdStore.js +12 -0
  52. package/dist/cjs/wallets/injected/mipdStore.js.map +1 -1
  53. package/dist/esm/bridge/Buy.js +16 -12
  54. package/dist/esm/bridge/Buy.js.map +1 -1
  55. package/dist/esm/bridge/Chains.js +2 -2
  56. package/dist/esm/bridge/Chains.js.map +1 -1
  57. package/dist/esm/bridge/Routes.js +2 -2
  58. package/dist/esm/bridge/Routes.js.map +1 -1
  59. package/dist/esm/bridge/Sell.js +17 -13
  60. package/dist/esm/bridge/Sell.js.map +1 -1
  61. package/dist/esm/bridge/Status.js +15 -2
  62. package/dist/esm/bridge/Status.js.map +1 -1
  63. package/dist/esm/bridge/Transfer.js +226 -0
  64. package/dist/esm/bridge/Transfer.js.map +1 -0
  65. package/dist/esm/bridge/index.js +1 -0
  66. package/dist/esm/bridge/index.js.map +1 -1
  67. package/dist/esm/bridge/types/Token.js +2 -0
  68. package/dist/esm/bridge/types/Token.js.map +1 -0
  69. package/dist/esm/exports/wallets.js +1 -0
  70. package/dist/esm/exports/wallets.js.map +1 -1
  71. package/dist/esm/pay/buyWithCrypto/getQuote.js +159 -53
  72. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  73. package/dist/esm/pay/buyWithCrypto/getStatus.js +160 -14
  74. package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
  75. package/dist/esm/pay/buyWithCrypto/getTransfer.js +95 -37
  76. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
  77. package/dist/esm/pay/utils/definitions.js +0 -25
  78. package/dist/esm/pay/utils/definitions.js.map +1 -1
  79. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +23 -21
  80. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  81. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
  82. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  84. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +1 -134
  86. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  89. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +1 -1
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +84 -34
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  95. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
  96. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  97. package/dist/esm/utils/any-evm/zksync/constants.js +1 -0
  98. package/dist/esm/utils/any-evm/zksync/constants.js.map +1 -1
  99. package/dist/esm/utils/domains.js +3 -0
  100. package/dist/esm/utils/domains.js.map +1 -1
  101. package/dist/esm/version.js +1 -1
  102. package/dist/esm/version.js.map +1 -1
  103. package/dist/esm/wallets/injected/mipdStore.js +11 -0
  104. package/dist/esm/wallets/injected/mipdStore.js.map +1 -1
  105. package/dist/types/bridge/Buy.d.ts +10 -8
  106. package/dist/types/bridge/Buy.d.ts.map +1 -1
  107. package/dist/types/bridge/Sell.d.ts +12 -10
  108. package/dist/types/bridge/Sell.d.ts.map +1 -1
  109. package/dist/types/bridge/Status.d.ts.map +1 -1
  110. package/dist/types/bridge/Transfer.d.ts +199 -0
  111. package/dist/types/bridge/Transfer.d.ts.map +1 -0
  112. package/dist/types/bridge/index.d.ts +1 -0
  113. package/dist/types/bridge/index.d.ts.map +1 -1
  114. package/dist/types/bridge/types/Route.d.ts +3 -17
  115. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  116. package/dist/types/bridge/types/Status.d.ts +15 -0
  117. package/dist/types/bridge/types/Status.d.ts.map +1 -1
  118. package/dist/types/bridge/types/Token.d.ts +10 -0
  119. package/dist/types/bridge/types/Token.d.ts.map +1 -0
  120. package/dist/types/exports/wallets.d.ts +1 -0
  121. package/dist/types/exports/wallets.d.ts.map +1 -1
  122. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +0 -9
  123. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -1
  124. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  125. package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
  126. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  127. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
  128. package/dist/types/pay/utils/definitions.d.ts +0 -25
  129. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  130. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  131. package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
  132. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +2 -13
  133. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +1 -1
  134. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
  135. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts +0 -1
  136. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts.map +1 -1
  137. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +8 -4
  138. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
  139. package/dist/types/react/web/ui/MediaRenderer/MediaRenderer.d.ts +1 -1
  140. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
  141. package/dist/types/utils/any-evm/zksync/constants.d.ts.map +1 -1
  142. package/dist/types/utils/domains.d.ts +6 -0
  143. package/dist/types/utils/domains.d.ts.map +1 -1
  144. package/dist/types/version.d.ts +1 -1
  145. package/dist/types/version.d.ts.map +1 -1
  146. package/dist/types/wallets/injected/mipdStore.d.ts +7 -0
  147. package/dist/types/wallets/injected/mipdStore.d.ts.map +1 -1
  148. package/package.json +1 -1
  149. package/src/bridge/Buy.ts +18 -12
  150. package/src/bridge/Chains.ts +2 -2
  151. package/src/bridge/Routes.ts +2 -2
  152. package/src/bridge/Sell.ts +19 -13
  153. package/src/bridge/Status.ts +15 -2
  154. package/src/bridge/Transfer.test.ts +76 -0
  155. package/src/bridge/Transfer.ts +270 -0
  156. package/src/bridge/index.ts +1 -0
  157. package/src/bridge/types/Route.ts +3 -17
  158. package/src/bridge/types/Status.ts +15 -1
  159. package/src/bridge/types/Token.ts +10 -0
  160. package/src/exports/wallets.ts +1 -0
  161. package/src/extensions/prebuilts/deploy-modular-core.test.ts +2 -1
  162. package/src/pay/buyWithCrypto/commonTypes.ts +0 -10
  163. package/src/pay/buyWithCrypto/getQuote.ts +210 -100
  164. package/src/pay/buyWithCrypto/getStatus.ts +213 -20
  165. package/src/pay/buyWithCrypto/getTransfer.ts +129 -61
  166. package/src/pay/utils/definitions.ts +0 -34
  167. package/src/react/core/hooks/transaction/useSendTransaction.ts +27 -33
  168. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +29 -35
  169. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
  170. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +2 -181
  171. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +3 -1
  172. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +1 -1
  173. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.ts +1 -3
  174. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +118 -63
  175. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +0 -2
  176. package/src/utils/any-evm/zksync/constants.ts +1 -0
  177. package/src/utils/domain.test.ts +1 -0
  178. package/src/utils/domains.ts +8 -0
  179. package/src/version.ts +1 -1
  180. package/src/wallets/injected/mipdStore.ts +14 -0
  181. package/dist/cjs/bridge/constants.js +0 -5
  182. package/dist/cjs/bridge/constants.js.map +0 -1
  183. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -54
  184. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  185. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -52
  186. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  187. package/dist/esm/bridge/constants.js +0 -2
  188. package/dist/esm/bridge/constants.js.map +0 -1
  189. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -51
  190. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  191. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -48
  192. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  193. package/dist/types/bridge/constants.d.ts +0 -2
  194. package/dist/types/bridge/constants.d.ts.map +0 -1
  195. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +0 -10
  196. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +0 -1
  197. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts +0 -9
  198. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts.map +0 -1
  199. package/src/bridge/constants.ts +0 -1
  200. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +0 -163
  201. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.tsx +0 -127
@@ -0,0 +1,270 @@
1
+ import type { Address as ox__Address } from "ox";
2
+ import { defineChain } from "../chains/utils.js";
3
+ import type { ThirdwebClient } from "../client/client.js";
4
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
5
+ import { getClientFetch } from "../utils/fetch.js";
6
+ import { stringify } from "../utils/json.js";
7
+ import type { PreparedQuote } from "./types/Quote.js";
8
+
9
+ /**
10
+ * Prepares a **finalized** Universal Bridge quote for the provided transfer request with transaction data.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
15
+ *
16
+ * const quote = await Bridge.Transfer.prepare({
17
+ * chainId: 1,
18
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
19
+ * amount: toWei("0.01"),
20
+ * sender: "0x...",
21
+ * receiver: "0x...",
22
+ * client: thirdwebClient,
23
+ * });
24
+ * ```
25
+ *
26
+ * This will return a quote that might look like:
27
+ * ```typescript
28
+ * {
29
+ * originAmount: 10000026098875381n,
30
+ * destinationAmount: 10000000000000000n,
31
+ * blockNumber: 22026509n,
32
+ * timestamp: 1741730936680,
33
+ * estimatedExecutionTimeMs: 1000
34
+ * steps: [
35
+ * {
36
+ * originToken: {
37
+ * chainId: 1,
38
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
39
+ * symbol: "ETH",
40
+ * name: "Ethereum",
41
+ * decimals: 18,
42
+ * priceUsd: 2000,
43
+ * iconUri: "https://..."
44
+ * },
45
+ * destinationToken: {
46
+ * chainId: 1,
47
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
48
+ * symbol: "ETH",
49
+ * name: "Ethereum",
50
+ * decimals: 18,
51
+ * priceUsd: 2000,
52
+ * iconUri: "https://..."
53
+ * },
54
+ * originAmount: 10000026098875381n,
55
+ * destinationAmount: 10000000000000000n,
56
+ * estimatedExecutionTimeMs: 1000
57
+ * transactions: [
58
+ * {
59
+ * action: "approval",
60
+ * id: "0x",
61
+ * to: "0x...",
62
+ * data: "0x...",
63
+ * chainId: 1,
64
+ * type: "eip1559"
65
+ * },
66
+ * {
67
+ * action: "transfer",
68
+ * to: "0x...",
69
+ * value: 10000026098875381n,
70
+ * data: "0x...",
71
+ * chainId: 1,
72
+ * type: "eip1559"
73
+ * }
74
+ * ]
75
+ * }
76
+ * ],
77
+ * expiration: 1741730936680,
78
+ * intent: {
79
+ * chainId: 1,
80
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
81
+ * amount: 10000000000000000n,
82
+ * sender: "0x...",
83
+ * receiver: "0x..."
84
+ * }
85
+ * }
86
+ * ```
87
+ *
88
+ * ## Sending the transactions
89
+ * 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:
90
+ * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
91
+ * - 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.
92
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
93
+ *
94
+ * 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.
95
+ *
96
+ * You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
97
+ *
98
+ * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
99
+ *
100
+ * ```ts
101
+ * const quote = await Bridge.Transfer.prepare({
102
+ * chainId: 1,
103
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
104
+ * amount: toWei("0.01"),
105
+ * sender: "0x...",
106
+ * receiver: "0x...",
107
+ * purchaseData: {
108
+ * reference: "payment-123",
109
+ * metadata: {
110
+ * note: "Transfer to Alice"
111
+ * }
112
+ * },
113
+ * client: thirdwebClient,
114
+ * });
115
+ * ```
116
+ *
117
+ * ## Fees
118
+ * 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.
119
+ *
120
+ * For example, if you were to request a transfer with `feePayer` set to `receiver`:
121
+ * ```typescript
122
+ * const quote = await Bridge.Transfer.prepare({
123
+ * chainId: 1,
124
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
125
+ * amount: 100_000_000n, // 100 USDC
126
+ * sender: "0x...",
127
+ * receiver: "0x...",
128
+ * feePayer: "receiver",
129
+ * client: thirdwebClient,
130
+ * });
131
+ * ```
132
+ *
133
+ * The returned quote might look like:
134
+ * ```typescript
135
+ * {
136
+ * originAmount: 100_000_000n, // 100 USDC
137
+ * destinationAmount: 99_970_000n, // 99.97 USDC
138
+ * ...
139
+ * }
140
+ * ```
141
+ *
142
+ * If you were to request a transfer with `feePayer` set to `sender`:
143
+ * ```typescript
144
+ * const quote = await Bridge.Transfer.prepare({
145
+ * chainId: 1,
146
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
147
+ * amount: 100_000_000n, // 100 USDC
148
+ * sender: "0x...",
149
+ * receiver: "0x...",
150
+ * feePayer: "sender",
151
+ * client: thirdwebClient,
152
+ * });
153
+ * ```
154
+ *
155
+ * The returned quote might look like:
156
+ * ```typescript
157
+ * {
158
+ * originAmount: 100_030_000n, // 100.03 USDC
159
+ * destinationAmount: 100_000_000n, // 100 USDC
160
+ * ...
161
+ * }
162
+ * ```
163
+ *
164
+ * @param options - The options for the quote.
165
+ * @param options.chainId - The chain ID of the token.
166
+ * @param options.tokenAddress - The address of the token.
167
+ * @param options.amount - The amount of the token to transfer.
168
+ * @param options.sender - The address of the sender.
169
+ * @param options.receiver - The address of the recipient.
170
+ * @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
171
+ * @param options.client - Your thirdweb client.
172
+ * @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".
173
+ *
174
+ * @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
175
+ *
176
+ * @throws Will throw an error if there is an issue fetching the quote.
177
+ * @bridge Transfer
178
+ * @beta
179
+ */
180
+ export async function prepare(
181
+ options: prepare.Options,
182
+ ): Promise<prepare.Result> {
183
+ const {
184
+ chainId,
185
+ tokenAddress,
186
+ sender,
187
+ receiver,
188
+ client,
189
+ amount,
190
+ purchaseData,
191
+ feePayer,
192
+ } = options;
193
+
194
+ const clientFetch = getClientFetch(client);
195
+ const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/transfer/prepare`);
196
+
197
+ const response = await clientFetch(url.toString(), {
198
+ method: "POST",
199
+ headers: {
200
+ "Content-Type": "application/json",
201
+ },
202
+ body: stringify({
203
+ transferAmountWei: amount.toString(), // legacy
204
+ amount: amount.toString(),
205
+ chainId: chainId.toString(),
206
+ tokenAddress,
207
+ sender,
208
+ receiver,
209
+ purchaseData,
210
+ feePayer,
211
+ }),
212
+ });
213
+ if (!response.ok) {
214
+ const errorJson = await response.json();
215
+ throw new Error(
216
+ `${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
217
+ );
218
+ }
219
+
220
+ const { data }: { data: PreparedQuote } = await response.json();
221
+ return {
222
+ originAmount: BigInt(data.originAmount),
223
+ destinationAmount: BigInt(data.destinationAmount),
224
+ blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
225
+ timestamp: data.timestamp,
226
+ estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
227
+ steps: data.steps.map((step) => ({
228
+ ...step,
229
+ transactions: step.transactions.map((transaction) => ({
230
+ ...transaction,
231
+ value: transaction.value ? BigInt(transaction.value) : undefined,
232
+ client,
233
+ chain: defineChain(transaction.chainId),
234
+ })),
235
+ })),
236
+ intent: {
237
+ chainId,
238
+ tokenAddress,
239
+ amount,
240
+ sender,
241
+ receiver,
242
+ feePayer,
243
+ },
244
+ };
245
+ }
246
+
247
+ export declare namespace prepare {
248
+ type Options = {
249
+ chainId: number;
250
+ tokenAddress: ox__Address.Address;
251
+ sender: ox__Address.Address;
252
+ receiver: ox__Address.Address;
253
+ amount: bigint;
254
+ client: ThirdwebClient;
255
+ purchaseData?: unknown;
256
+ feePayer?: "sender" | "receiver";
257
+ };
258
+
259
+ type Result = PreparedQuote & {
260
+ intent: {
261
+ chainId: number;
262
+ tokenAddress: ox__Address.Address;
263
+ amount: bigint;
264
+ sender: ox__Address.Address;
265
+ receiver: ox__Address.Address;
266
+ purchaseData?: unknown;
267
+ feePayer?: "sender" | "receiver";
268
+ };
269
+ };
270
+ }
@@ -1,5 +1,6 @@
1
1
  export * as Buy from "./Buy.js";
2
2
  export * as Sell from "./Sell.js";
3
+ export * as Transfer from "./Transfer.js";
3
4
  export { status } from "./Status.js";
4
5
  export { routes } from "./Routes.js";
5
6
  export { chains } from "./Chains.js";
@@ -1,20 +1,6 @@
1
- import type { Address as ox__Address } from "ox";
1
+ import type { Token } from "./Token.js";
2
2
 
3
3
  export type Route = {
4
- originToken: {
5
- chainId: number;
6
- address: ox__Address.Address;
7
- decimals: number;
8
- symbol: string;
9
- name: string;
10
- iconUri?: string;
11
- };
12
- destinationToken: {
13
- chainId: number;
14
- address: string;
15
- decimals: number;
16
- symbol: string;
17
- name: string;
18
- iconUri?: string;
19
- };
4
+ originToken: Token;
5
+ destinationToken: Token;
20
6
  };
@@ -1,14 +1,19 @@
1
1
  import type { Address as ox__Address, Hex as ox__Hex } from "ox";
2
-
2
+ import type { Token } from "./Token.js";
3
3
  export type Status =
4
4
  | {
5
5
  status: "COMPLETED";
6
+ paymentId: string;
6
7
  originAmount: bigint;
7
8
  destinationAmount: bigint;
8
9
  originChainId: number;
9
10
  destinationChainId: number;
10
11
  originTokenAddress: ox__Address.Address;
11
12
  destinationTokenAddress: ox__Address.Address;
13
+ originToken: Token;
14
+ destinationToken: Token;
15
+ sender: ox__Address.Address;
16
+ receiver: ox__Address.Address;
12
17
  transactions: Array<{
13
18
  chainId: number;
14
19
  transactionHash: ox__Hex.Hex;
@@ -17,24 +22,33 @@ export type Status =
17
22
  }
18
23
  | {
19
24
  status: "PENDING";
25
+ paymentId: string;
20
26
  originAmount: bigint;
21
27
  originChainId: number;
22
28
  destinationChainId: number;
23
29
  originTokenAddress: ox__Address.Address;
24
30
  destinationTokenAddress: ox__Address.Address;
31
+ originToken: Token;
32
+ destinationToken: Token;
33
+ sender: ox__Address.Address;
34
+ receiver: ox__Address.Address;
25
35
  transactions: Array<{
26
36
  chainId: number;
27
37
  transactionHash: ox__Hex.Hex;
28
38
  }>;
39
+ purchaseData?: unknown;
29
40
  }
30
41
  | {
31
42
  status: "FAILED";
43
+ paymentId: string;
32
44
  transactions: Array<{
33
45
  chainId: number;
34
46
  transactionHash: ox__Hex.Hex;
35
47
  }>;
48
+ purchaseData?: unknown;
36
49
  }
37
50
  | {
38
51
  status: "NOT_FOUND";
52
+ paymentId: string;
39
53
  transactions: [];
40
54
  };
@@ -0,0 +1,10 @@
1
+ import type { Address as ox__Address } from "ox";
2
+
3
+ export type Token = {
4
+ chainId: number;
5
+ address: ox__Address.Address;
6
+ decimals: number;
7
+ symbol: string;
8
+ name: string;
9
+ iconUri?: string;
10
+ };
@@ -160,6 +160,7 @@ export * as EIP1193 from "../adapters/eip1193/index.js";
160
160
 
161
161
  // injected
162
162
  export { injectedProvider } from "../wallets/injected/mipdStore.js";
163
+ export { getInstalledWallets } from "../wallets/injected/mipdStore.js";
163
164
 
164
165
  export type { ConnectionManager } from "../wallets/manager/index.js";
165
166
 
@@ -17,7 +17,8 @@ import {
17
17
  deployPublishedContract,
18
18
  } from "./deploy-published.js";
19
19
 
20
- describe.runIf(process.env.TW_SECRET_KEY)(
20
+ // TODO: fix the 410 IPFS error in this test
21
+ describe.runIf(process.env.TW_SECRET_KEY).todo(
21
22
  "deployModularCore",
22
23
  {
23
24
  timeout: 120000,
@@ -10,16 +10,6 @@ export type QuoteTokenInfo = {
10
10
  symbol?: string;
11
11
  };
12
12
 
13
- export type QuoteTransactionRequest = {
14
- data: string;
15
- to: string;
16
- value: string;
17
- from: string;
18
- chainId: number;
19
- gasPrice: string;
20
- gasLimit: string;
21
- };
22
-
23
13
  export type QuoteApprovalInfo = {
24
14
  chainId: number;
25
15
  tokenAddress: string;