thirdweb 5.103.1 → 5.104.0-nightly-6be945936195e6ba41dbdd3a90a28f097e81dbee-20250620000408

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 (68) hide show
  1. package/dist/cjs/chains/chain-definitions/berachain-bepolia.js +20 -0
  2. package/dist/cjs/chains/chain-definitions/berachain-bepolia.js.map +1 -0
  3. package/dist/cjs/chains/chain-definitions/berachain.js +20 -0
  4. package/dist/cjs/chains/chain-definitions/berachain.js.map +1 -0
  5. package/dist/cjs/exports/chains.js +5 -1
  6. package/dist/cjs/exports/chains.js.map +1 -1
  7. package/dist/cjs/insight/get-tokens.js +1 -1
  8. package/dist/cjs/insight/get-tokens.js.map +1 -1
  9. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +7 -9
  10. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  11. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js +1 -2
  12. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  13. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js +14 -7
  14. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  15. package/dist/cjs/react/web/ui/Bridge/payment-success/PaymentReceipt.js +2 -1
  16. package/dist/cjs/react/web/ui/Bridge/payment-success/PaymentReceipt.js.map +1 -1
  17. package/dist/cjs/react/web/ui/MediaRenderer/MediaRenderer.js +4 -0
  18. package/dist/cjs/react/web/ui/MediaRenderer/MediaRenderer.js.map +1 -1
  19. package/dist/cjs/version.js +1 -1
  20. package/dist/cjs/version.js.map +1 -1
  21. package/dist/esm/chains/chain-definitions/berachain-bepolia.js +17 -0
  22. package/dist/esm/chains/chain-definitions/berachain-bepolia.js.map +1 -0
  23. package/dist/esm/chains/chain-definitions/berachain.js +17 -0
  24. package/dist/esm/chains/chain-definitions/berachain.js.map +1 -0
  25. package/dist/esm/exports/chains.js +2 -0
  26. package/dist/esm/exports/chains.js.map +1 -1
  27. package/dist/esm/insight/get-tokens.js +1 -1
  28. package/dist/esm/insight/get-tokens.js.map +1 -1
  29. package/dist/esm/react/web/ui/Bridge/BuyWidget.js +7 -9
  30. package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  31. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js +1 -2
  32. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  33. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js +14 -7
  34. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  35. package/dist/esm/react/web/ui/Bridge/payment-success/PaymentReceipt.js +2 -1
  36. package/dist/esm/react/web/ui/Bridge/payment-success/PaymentReceipt.js.map +1 -1
  37. package/dist/esm/react/web/ui/MediaRenderer/MediaRenderer.js +4 -0
  38. package/dist/esm/react/web/ui/MediaRenderer/MediaRenderer.js.map +1 -1
  39. package/dist/esm/version.js +1 -1
  40. package/dist/esm/version.js.map +1 -1
  41. package/dist/types/chains/chain-definitions/berachain-bepolia.d.ts +7 -0
  42. package/dist/types/chains/chain-definitions/berachain-bepolia.d.ts.map +1 -0
  43. package/dist/types/chains/chain-definitions/berachain.d.ts +7 -0
  44. package/dist/types/chains/chain-definitions/berachain.d.ts.map +1 -0
  45. package/dist/types/exports/chains.d.ts +2 -0
  46. package/dist/types/exports/chains.d.ts.map +1 -1
  47. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts +7 -8
  48. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
  49. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts +2 -2
  50. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
  51. package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts +3 -3
  52. package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts.map +1 -1
  53. package/dist/types/react/web/ui/Bridge/payment-success/PaymentReceipt.d.ts.map +1 -1
  54. package/dist/types/react/web/ui/MediaRenderer/MediaRenderer.d.ts.map +1 -1
  55. package/dist/types/version.d.ts +1 -1
  56. package/dist/types/version.d.ts.map +1 -1
  57. package/package.json +1 -1
  58. package/src/chains/chain-definitions/berachain-bepolia.ts +17 -0
  59. package/src/chains/chain-definitions/berachain.ts +17 -0
  60. package/src/exports/chains.ts +2 -0
  61. package/src/insight/get-tokens.ts +1 -1
  62. package/src/react/web/ui/Bridge/BuyWidget.tsx +9 -11
  63. package/src/react/web/ui/Bridge/CheckoutWidget.tsx +3 -4
  64. package/src/react/web/ui/Bridge/TransactionWidget.tsx +23 -11
  65. package/src/react/web/ui/Bridge/payment-success/PaymentReceipt.tsx +3 -1
  66. package/src/react/web/ui/MediaRenderer/MediaRenderer.test.tsx +21 -8
  67. package/src/react/web/ui/MediaRenderer/MediaRenderer.tsx +15 -0
  68. package/src/version.ts +1 -1
@@ -83,3 +83,5 @@ export { soneiumMinato } from "../chains/chain-definitions/soneium-minato.js";
83
83
  export { treasure } from "../chains/chain-definitions/treasure.js";
84
84
  export { treasureTopaz } from "../chains/chain-definitions/treasureTopaz.js";
85
85
  export { monadTestnet } from "../chains/chain-definitions/monad-testnet.js";
86
+ export { berachain } from "../chains/chain-definitions/berachain.js";
87
+ export { berachainBepolia } from "../chains/chain-definitions/berachain-bepolia.js";
@@ -51,7 +51,7 @@ export async function getOwnedTokens(args: {
51
51
 
52
52
  const defaultQueryOptions: GetV1TokensData["query"] = {
53
53
  owner_address: ownerAddress,
54
- chain_id: chains.map((chain) => chain.id),
54
+ chain_id: chains.length > 0 ? chains.map((chain) => chain.id) : [1],
55
55
  include_native: "true",
56
56
  include_spam: "false",
57
57
  metadata: "true",
@@ -12,7 +12,6 @@ import {
12
12
  isAddress,
13
13
  } from "../../../../utils/address.js";
14
14
  import { stringify } from "../../../../utils/json.js";
15
- import { toTokens } from "../../../../utils/units.js";
16
15
  import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
17
16
  import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
18
17
  import type { AppMetadata } from "../../../../wallets/types.js";
@@ -112,9 +111,9 @@ export type BuyWidgetProps = {
112
111
  tokenAddress?: Address;
113
112
 
114
113
  /**
115
- * The amount to buy **(in wei)**.
114
+ * The amount to buy **(as a decimal string)**, e.g. "1.5" for 1.5 tokens.
116
115
  */
117
- amount: bigint;
116
+ amount: string;
118
117
 
119
118
  /**
120
119
  * The title to display in the widget.
@@ -178,12 +177,11 @@ type UIOptionsResult =
178
177
  *
179
178
  * ```tsx
180
179
  * import { ethereum } from "thirdweb/chains";
181
- * import { toWei } from "thirdweb";
182
180
  *
183
181
  * <BuyWidget
184
182
  * client={client}
185
183
  * chain={ethereum}
186
- * amount={toWei("0.1")}
184
+ * amount="0.1"
187
185
  * />
188
186
  * ```
189
187
  *
@@ -195,7 +193,7 @@ type UIOptionsResult =
195
193
  * <BuyWidget
196
194
  * client={client}
197
195
  * chain={ethereum}
198
- * amount={toWei("100")}
196
+ * amount="100"
199
197
  * tokenAddress="0xA0b86a33E6417E4df2057B2d3C6d9F7cc11b0a70"
200
198
  * />
201
199
  * ```
@@ -208,7 +206,7 @@ type UIOptionsResult =
208
206
  * <BuyWidget
209
207
  * client={client}
210
208
  * chain={ethereum}
211
- * amount={toWei("0.1")}
209
+ * amount="0.1"
212
210
  * theme={darkTheme({
213
211
  * colors: {
214
212
  * modalBg: "red",
@@ -227,7 +225,7 @@ type UIOptionsResult =
227
225
  * <BuyWidget
228
226
  * client={client}
229
227
  * chain={ethereum}
230
- * amount={toWei("0.1")}
228
+ * amount="0.1"
231
229
  * title="Buy ETH"
232
230
  * />
233
231
  * ```
@@ -240,7 +238,7 @@ type UIOptionsResult =
240
238
  * <BuyWidget
241
239
  * client={client}
242
240
  * chain={ethereum}
243
- * amount={toWei("0.1")}
241
+ * amount="0.1"
244
242
  * connectOptions={{
245
243
  * connectModal: {
246
244
  * size: 'compact',
@@ -279,7 +277,7 @@ export function BuyWidget(props: BuyWidgetProps) {
279
277
  data: {
280
278
  mode: "fund_wallet",
281
279
  destinationToken: ETH,
282
- initialAmount: toTokens(props.amount, ETH.decimals),
280
+ initialAmount: props.amount,
283
281
  },
284
282
  };
285
283
  }
@@ -303,7 +301,7 @@ export function BuyWidget(props: BuyWidgetProps) {
303
301
  data: {
304
302
  mode: "fund_wallet",
305
303
  destinationToken: token,
306
- initialAmount: toTokens(props.amount, token.decimals),
304
+ initialAmount: props.amount,
307
305
  metadata: {
308
306
  title: props.title,
309
307
  },
@@ -8,7 +8,6 @@ import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
8
8
  import { getToken } from "../../../../pay/convert/get-token.js";
9
9
  import { type Address, checksumAddress } from "../../../../utils/address.js";
10
10
  import { stringify } from "../../../../utils/json.js";
11
- import { toTokens } from "../../../../utils/units.js";
12
11
  import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
13
12
  import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
14
13
  import type { AppMetadata } from "../../../../wallets/types.js";
@@ -108,9 +107,9 @@ export type CheckoutWidgetProps = {
108
107
  tokenAddress?: Address;
109
108
 
110
109
  /**
111
- * The price of the item **(in wei)**.
110
+ * The price of the item **(as a decimal string)**, e.g. "1.5" for 1.5 tokens.
112
111
  */
113
- amount: bigint;
112
+ amount: string;
114
113
 
115
114
  /**
116
115
  * The wallet address or ENS funds will be paid to.
@@ -282,7 +281,7 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
282
281
  },
283
282
  paymentInfo: {
284
283
  token,
285
- amount: toTokens(props.amount, token.decimals),
284
+ amount: props.amount,
286
285
  sellerAddress: props.seller,
287
286
  feePayer: props.feePayer === "seller" ? "receiver" : "sender", // User is sender, seller is receiver
288
287
  },
@@ -5,12 +5,14 @@ import type { Token } from "../../../../bridge/index.js";
5
5
  import type { Chain } from "../../../../chains/types.js";
6
6
  import type { ThirdwebClient } from "../../../../client/client.js";
7
7
  import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
8
+ import { getToken } from "../../../../pay/convert/get-token.js";
8
9
  import {
9
10
  type PreparedTransaction,
10
11
  prepareTransaction,
11
12
  } from "../../../../transaction/prepare-transaction.js";
12
13
  import { type Address, checksumAddress } from "../../../../utils/address.js";
13
14
  import { stringify } from "../../../../utils/json.js";
15
+ import { toUnits } from "../../../../utils/units.js";
14
16
  import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
15
17
  import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
16
18
  import type { AppMetadata } from "../../../../wallets/types.js";
@@ -105,9 +107,9 @@ export type TransactionWidgetProps = {
105
107
  tokenAddress?: Address;
106
108
 
107
109
  /**
108
- * The price of the item **(in wei)**.
110
+ * The price of the item **(as a decimal string)**, e.g. "1.5" for 1.5 tokens.
109
111
  */
110
- amount?: bigint;
112
+ amount?: string;
111
113
 
112
114
  /**
113
115
  * A title for the transaction.
@@ -196,8 +198,8 @@ type UIOptionsResult =
196
198
  * to: "0x...",
197
199
  * chain: ethereum,
198
200
  * client: client,
199
- * value: toUnits("0.001", 18),
200
201
  * })}
202
+ * amount="0.1"
201
203
  * />
202
204
  * ```
203
205
  *
@@ -276,16 +278,26 @@ export function TransactionWidget(props: TransactionWidgetProps) {
276
278
  const bridgeDataQuery = useQuery({
277
279
  queryKey: ["bridgeData", stringify(props)],
278
280
  queryFn: async (): Promise<UIOptionsResult> => {
281
+ let erc20Value = props.transaction.erc20Value;
282
+
283
+ if (props.amount) {
284
+ // Get token decimals for conversion
285
+ const tokenAddress = props.tokenAddress || NATIVE_TOKEN_ADDRESS;
286
+ const token = await getToken(
287
+ props.client,
288
+ checksumAddress(tokenAddress),
289
+ props.transaction.chain.id,
290
+ );
291
+
292
+ erc20Value = {
293
+ amountWei: toUnits(props.amount, token.decimals),
294
+ tokenAddress: checksumAddress(tokenAddress),
295
+ };
296
+ }
297
+
279
298
  const transaction = prepareTransaction({
280
299
  ...props.transaction,
281
- erc20Value: props.amount
282
- ? {
283
- amountWei: props.amount,
284
- tokenAddress: checksumAddress(
285
- props.tokenAddress || NATIVE_TOKEN_ADDRESS,
286
- ),
287
- }
288
- : props.transaction.erc20Value,
300
+ erc20Value,
289
301
  });
290
302
 
291
303
  return {
@@ -33,6 +33,7 @@ interface TransactionInfo {
33
33
  label: string;
34
34
  chain: ChainMetadata;
35
35
  destinationToken?: Token;
36
+ destinationChain?: ChainMetadata;
36
37
  originToken?: Token;
37
38
  originChain?: ChainMetadata;
38
39
  amountPaid?: string;
@@ -102,6 +103,7 @@ function useTransactionInfo(
102
103
  originToken: status.originToken,
103
104
  originChain,
104
105
  destinationToken: status.destinationToken,
106
+ destinationChain,
105
107
  amountReceived: `${formatTokenAmount(
106
108
  status.destinationAmount,
107
109
  status.destinationToken.decimals,
@@ -228,7 +230,7 @@ function CompletedStepDetailCard({
228
230
  Origin Chain
229
231
  </Text>
230
232
  <Text size="sm" color="primaryText">
231
- {shorterChainName(txInfo.chain.name)}
233
+ {shorterChainName(txInfo.originChain.name)}
232
234
  </Text>
233
235
  </Container>
234
236
  )}
@@ -14,6 +14,11 @@ import {
14
14
  mergeRefs,
15
15
  } from "./MediaRenderer.js";
16
16
 
17
+ const three3dModelLink =
18
+ "https://i2.seadn.io/matic/0x2953399124f0cbb46d2cbacd8a89cf0599974963/bd1801876c5cf1302484e225c72959/49bd1801876c5cf1302484e225c72959.glb";
19
+ const imageLink =
20
+ "https://i.seadn.io/gae/r_b9GB0iYA39ichUlKdFLeG4UliK7YXi9SsM0Xdvm6pNDChYbN5E7Fxop1MdJCbmNvSlbER73YiA9WY1JbhEfkuIktoHfN9UlEZy4A?auto=format&dpr=1&w=1000";
21
+
17
22
  describe("MediaRenderer", () => {
18
23
  it("should render nothing if no src provided", () => {
19
24
  render(<MediaRenderer client={TEST_CLIENT} />);
@@ -27,14 +32,9 @@ describe("MediaRenderer", () => {
27
32
  }, 1000);
28
33
  });
29
34
 
30
- it("should render a plain image", () => {
31
- render(
32
- <MediaRenderer
33
- client={TEST_CLIENT}
34
- src="https://i.seadn.io/gae/r_b9GB0iYA39ichUlKdFLeG4UliK7YXi9SsM0Xdvm6pNDChYbN5E7Fxop1MdJCbmNvSlbER73YiA9WY1JbhEfkuIktoHfN9UlEZy4A?auto=format&dpr=1&w=1000"
35
- />,
36
- );
37
- waitFor(() => {
35
+ it("should render a plain image", async () => {
36
+ render(<MediaRenderer client={TEST_CLIENT} src={imageLink} />);
37
+ await waitFor(() => {
38
38
  expect(screen.getByRole("img")).toBeInTheDocument();
39
39
  });
40
40
  });
@@ -222,4 +222,17 @@ describe("MediaRenderer", () => {
222
222
  expect(iframe).toHaveAttribute("src", "https://example.com/video");
223
223
  });
224
224
  });
225
+
226
+ it("should render poster image for 3d models", async () => {
227
+ render(
228
+ <MediaRenderer
229
+ client={TEST_CLIENT}
230
+ src={three3dModelLink}
231
+ poster={imageLink}
232
+ />,
233
+ );
234
+ await waitFor(() => {
235
+ expect(screen.getByRole("img")).toBeInTheDocument();
236
+ });
237
+ });
225
238
  });
@@ -111,6 +111,21 @@ export const MediaRenderer = /* @__PURE__ */ (() =>
111
111
  console.error(
112
112
  "Encountered an unsupported media type. 3D model support was removed in v5.92.0. To add a 3D model to your app, use @google/model-viewer and use the ModelViewer component.",
113
113
  );
114
+
115
+ // show poster
116
+ if (possiblePosterSrc.mimeType?.startsWith("image/")) {
117
+ return (
118
+ <ImageRenderer
119
+ style={mergedStyle}
120
+ src={possiblePosterSrc.url}
121
+ alt={alt}
122
+ ref={ref as unknown as React.ForwardedRef<HTMLImageElement>}
123
+ className={className}
124
+ height={height}
125
+ width={width}
126
+ />
127
+ );
128
+ }
114
129
  }
115
130
 
116
131
  // video
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.103.1";
1
+ export const version = "5.104.0-nightly-6be945936195e6ba41dbdd3a90a28f097e81dbee-20250620000408";