thirdweb 5.105.14 → 5.105.16-nightly-592bf6f1fdd4f1a2babbef94a37b93881d28b6f5-20250712000413

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 (58) hide show
  1. package/dist/cjs/engine/server-wallet.js +5 -3
  2. package/dist/cjs/engine/server-wallet.js.map +1 -1
  3. package/dist/cjs/react/core/hooks/useTransactionDetails.js +3 -2
  4. package/dist/cjs/react/core/hooks/useTransactionDetails.js.map +1 -1
  5. package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js +1 -0
  6. package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
  7. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js +26 -1
  8. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  9. package/dist/cjs/react/web/ui/Bridge/payment-selection/FiatProviderSelection.js +2 -1
  10. package/dist/cjs/react/web/ui/Bridge/payment-selection/FiatProviderSelection.js.map +1 -1
  11. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +4 -1
  12. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  13. package/dist/cjs/react/web/ui/ConnectWallet/Modal/AllWalletsUI.js +5 -3
  14. package/dist/cjs/react/web/ui/ConnectWallet/Modal/AllWalletsUI.js.map +1 -1
  15. package/dist/cjs/stories/ConnectButton/themes.stories.js +11 -1
  16. package/dist/cjs/stories/ConnectButton/themes.stories.js.map +1 -1
  17. package/dist/cjs/version.js +1 -1
  18. package/dist/cjs/version.js.map +1 -1
  19. package/dist/esm/engine/server-wallet.js +5 -3
  20. package/dist/esm/engine/server-wallet.js.map +1 -1
  21. package/dist/esm/react/core/hooks/useTransactionDetails.js +3 -2
  22. package/dist/esm/react/core/hooks/useTransactionDetails.js.map +1 -1
  23. package/dist/esm/react/native/ui/connect/ExternalWalletsList.js +1 -0
  24. package/dist/esm/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
  25. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js +26 -1
  26. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  27. package/dist/esm/react/web/ui/Bridge/payment-selection/FiatProviderSelection.js +2 -1
  28. package/dist/esm/react/web/ui/Bridge/payment-selection/FiatProviderSelection.js.map +1 -1
  29. package/dist/esm/react/web/ui/ConnectWallet/Details.js +4 -1
  30. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  31. package/dist/esm/react/web/ui/ConnectWallet/Modal/AllWalletsUI.js +5 -3
  32. package/dist/esm/react/web/ui/ConnectWallet/Modal/AllWalletsUI.js.map +1 -1
  33. package/dist/esm/stories/ConnectButton/themes.stories.js +10 -0
  34. package/dist/esm/stories/ConnectButton/themes.stories.js.map +1 -1
  35. package/dist/esm/version.js +1 -1
  36. package/dist/esm/version.js.map +1 -1
  37. package/dist/types/engine/server-wallet.d.ts +3 -2
  38. package/dist/types/engine/server-wallet.d.ts.map +1 -1
  39. package/dist/types/react/core/hooks/useTransactionDetails.d.ts.map +1 -1
  40. package/dist/types/react/native/ui/connect/ExternalWalletsList.d.ts.map +1 -1
  41. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
  42. package/dist/types/react/web/ui/Bridge/payment-selection/FiatProviderSelection.d.ts.map +1 -1
  43. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  44. package/dist/types/react/web/ui/ConnectWallet/Modal/AllWalletsUI.d.ts.map +1 -1
  45. package/dist/types/stories/ConnectButton/themes.stories.d.ts +1 -0
  46. package/dist/types/stories/ConnectButton/themes.stories.d.ts.map +1 -1
  47. package/dist/types/version.d.ts +1 -1
  48. package/dist/types/version.d.ts.map +1 -1
  49. package/package.json +3 -3
  50. package/src/engine/server-wallet.ts +8 -5
  51. package/src/react/core/hooks/useTransactionDetails.ts +6 -4
  52. package/src/react/native/ui/connect/ExternalWalletsList.tsx +4 -0
  53. package/src/react/web/ui/Bridge/TransactionPayment.tsx +34 -1
  54. package/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx +9 -3
  55. package/src/react/web/ui/ConnectWallet/Details.tsx +5 -0
  56. package/src/react/web/ui/ConnectWallet/Modal/AllWalletsUI.tsx +10 -3
  57. package/src/stories/ConnectButton/themes.stories.tsx +11 -0
  58. package/src/version.ts +1 -1
@@ -35,9 +35,10 @@ export type ServerWalletOptions = {
35
35
  */
36
36
  client: ThirdwebClient;
37
37
  /**
38
- * The vault access token to use your server wallet.
38
+ * Optional vault access token to use your server wallet.
39
+ * If not provided, the server wallet will use the project secret key to authenticate.
39
40
  */
40
- vaultAccessToken: string;
41
+ vaultAccessToken?: string;
41
42
  /**
42
43
  * The server wallet address to use for sending transactions inside engine.
43
44
  */
@@ -152,9 +153,11 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
152
153
  const { client, vaultAccessToken, address, chain, executionOptions } =
153
154
  options;
154
155
 
155
- const headers: HeadersInit = {
156
- "x-vault-access-token": vaultAccessToken,
157
- };
156
+ const headers: HeadersInit = vaultAccessToken
157
+ ? {
158
+ "x-vault-access-token": vaultAccessToken,
159
+ }
160
+ : {};
158
161
 
159
162
  const getExecutionOptionsWithChainId = (
160
163
  chainId: number,
@@ -81,7 +81,7 @@ export function useTransactionDetails({
81
81
  const [tokenInfo, gasCostWei] = await Promise.all([
82
82
  getToken(
83
83
  client,
84
- erc20Value ? erc20Value.tokenAddress : NATIVE_TOKEN_ADDRESS,
84
+ erc20Value?.tokenAddress || NATIVE_TOKEN_ADDRESS,
85
85
  transaction.chain.id,
86
86
  ).catch(() => null),
87
87
  hasSponsoredTransactions
@@ -151,9 +151,11 @@ export function useTransactionDetails({
151
151
  chainMetadata.data?.nativeCurrency?.symbol || "ETH";
152
152
  const tokenSymbol = tokenInfo?.symbol || nativeTokenSymbol;
153
153
 
154
- const totalCostWei = erc20Value
155
- ? erc20Value.amountWei
156
- : (value || 0n) + (gasCostWei || 0n);
154
+ const totalCostWei =
155
+ erc20Value &&
156
+ erc20Value.tokenAddress.toLowerCase() !== NATIVE_TOKEN_ADDRESS
157
+ ? erc20Value.amountWei
158
+ : (value || 0n) + (gasCostWei || 0n);
157
159
  const totalCost = toTokens(totalCostWei, decimal);
158
160
 
159
161
  const price = tokenInfo?.prices[currency || "USD"] || 0;
@@ -100,6 +100,10 @@ export function AllWalletsList(
100
100
  .filter(
101
101
  (info) => !externalWallets.find((wallet) => wallet.id === info.id),
102
102
  )
103
+ .filter(
104
+ (info) =>
105
+ info.id !== "inApp" && info.id !== "embedded" && info.id !== "smart",
106
+ )
103
107
  .filter((info) => info.hasMobileSupport);
104
108
 
105
109
  const fuse = new Fuse(filteredWallets, {
@@ -1,11 +1,15 @@
1
1
  "use client";
2
+ import { useQuery } from "@tanstack/react-query";
2
3
  import type { Token } from "../../../../bridge/index.js";
3
4
  import type { ThirdwebClient } from "../../../../client/client.js";
5
+ import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
4
6
  import {
5
7
  type Address,
6
8
  getAddress,
7
9
  shortenAddress,
8
10
  } from "../../../../utils/address.js";
11
+ import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
12
+ import { getWalletBalance } from "../../../../wallets/utils/getWalletBalance.js";
9
13
  import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
10
14
  import {
11
15
  fontSize,
@@ -77,6 +81,31 @@ export function TransactionPayment({
77
81
  wallet,
78
82
  });
79
83
 
84
+ // We can't use useWalletBalance here because erc20Value is a possibly async value
85
+ const { data: userBalance } = useQuery({
86
+ enabled: !!activeAccount?.address,
87
+ queryFn: async (): Promise<string> => {
88
+ if (!activeAccount?.address) {
89
+ return "0";
90
+ }
91
+ const erc20Value = await resolvePromisedValue(
92
+ uiOptions.transaction.erc20Value,
93
+ );
94
+ const walletBalance = await getWalletBalance({
95
+ address: activeAccount?.address,
96
+ chain: uiOptions.transaction.chain,
97
+ tokenAddress:
98
+ erc20Value?.tokenAddress.toLowerCase() !== NATIVE_TOKEN_ADDRESS
99
+ ? erc20Value?.tokenAddress
100
+ : undefined,
101
+ client,
102
+ });
103
+
104
+ return walletBalance.displayValue;
105
+ },
106
+ queryKey: ["user-balance", activeAccount?.address],
107
+ });
108
+
80
109
  const contractName =
81
110
  transactionDataQuery.data?.contractMetadata?.name || "Unknown Contract";
82
111
  const functionName =
@@ -327,7 +356,11 @@ export function TransactionPayment({
327
356
  onClick={() => {
328
357
  if (transactionDataQuery.data?.tokenInfo) {
329
358
  onContinue(
330
- transactionDataQuery.data.totalCost,
359
+ Math.max(
360
+ 0,
361
+ Number(transactionDataQuery.data.totalCost) -
362
+ Number(userBalance ?? "0"),
363
+ ).toString(),
331
364
  transactionDataQuery.data.tokenInfo,
332
365
  getAddress(activeAccount.address),
333
366
  );
@@ -3,6 +3,7 @@ import { useMemo } from "react";
3
3
  import type { ThirdwebClient } from "../../../../../client/client.js";
4
4
  import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
5
5
  import { checksumAddress } from "../../../../../utils/address.js";
6
+ import { formatNumber } from "../../../../../utils/formatNumber.js";
6
7
  import { toTokens } from "../../../../../utils/units.js";
7
8
  import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
8
9
  import {
@@ -171,9 +172,14 @@ export function FiatProviderSelection({
171
172
  {quote.currency}
172
173
  </Text>
173
174
  <Text color="secondaryText" size="xs">
174
- {toTokens(
175
- quote.destinationAmount,
176
- quote.destinationToken.decimals,
175
+ {formatNumber(
176
+ Number(
177
+ toTokens(
178
+ quote.destinationAmount,
179
+ quote.destinationToken.decimals,
180
+ ),
181
+ ),
182
+ 4,
177
183
  )}{" "}
178
184
  {quote.destinationToken.symbol}
179
185
  </Text>
@@ -978,6 +978,11 @@ export function DetailsModal(props: {
978
978
  onCancel={() => setScreen("main")}
979
979
  onSuccess={() => setScreen("main")}
980
980
  supportedTokens={props.supportedTokens}
981
+ theme={props.theme}
982
+ style={{
983
+ border: "none",
984
+ borderRadius: radius.lg,
985
+ }}
981
986
  tokenAddress={
982
987
  props.displayBalanceToken?.[Number(requestedChainId)] as
983
988
  | `0x${string}`
@@ -39,9 +39,16 @@ function AllWalletsUI(props: {
39
39
  const setSelectionData = useSetSelectionData();
40
40
 
41
41
  const walletList = useMemo(() => {
42
- return walletInfos.filter((wallet) => {
43
- return props.specifiedWallets.findIndex((x) => x.id === wallet.id) === -1;
44
- });
42
+ return walletInfos
43
+ .filter((wallet) => {
44
+ return (
45
+ props.specifiedWallets.findIndex((x) => x.id === wallet.id) === -1
46
+ );
47
+ })
48
+ .filter(
49
+ (info) =>
50
+ info.id !== "inApp" && info.id !== "embedded" && info.id !== "smart",
51
+ );
45
52
  }, [props.specifiedWallets]);
46
53
 
47
54
  const fuseInstance = useMemo(() => {
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { darkTheme } from "../../react/core/design-system/index.js";
2
3
  import { ConnectButton } from "../../react/web/ui/ConnectWallet/ConnectButton.js";
3
4
  import { storyClient } from "../utils.js";
4
5
 
@@ -27,4 +28,14 @@ export const Light: Story = {
27
28
  },
28
29
  };
29
30
 
31
+ export const CustomBlack: Story = {
32
+ args: {
33
+ theme: darkTheme({
34
+ colors: {
35
+ modalBg: "black",
36
+ },
37
+ }),
38
+ },
39
+ };
40
+
30
41
  export default meta;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.105.14";
1
+ export const version = "5.105.16-nightly-592bf6f1fdd4f1a2babbef94a37b93881d28b6f5-20250712000413";