thirdweb 5.105.34-nightly-92896ddf3f43cfa24d3b53d7b8b6c26f9b2b0c61-20250818000434 → 5.105.35

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 (45) hide show
  1. package/dist/cjs/exports/tokens.js +3 -1
  2. package/dist/cjs/exports/tokens.js.map +1 -1
  3. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +6 -3
  4. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  5. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js +2 -2
  6. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  7. package/dist/cjs/stories/ConnectWallet/useWalletDetailsModal.stories.js +130 -0
  8. package/dist/cjs/stories/ConnectWallet/useWalletDetailsModal.stories.js.map +1 -0
  9. package/dist/cjs/tokens/predict-address.js +39 -0
  10. package/dist/cjs/tokens/predict-address.js.map +1 -0
  11. package/dist/cjs/version.js +1 -1
  12. package/dist/cjs/version.js.map +1 -1
  13. package/dist/esm/exports/tokens.js +1 -0
  14. package/dist/esm/exports/tokens.js.map +1 -1
  15. package/dist/esm/react/web/ui/ConnectWallet/Details.js +6 -3
  16. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  17. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js +2 -2
  18. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  19. package/dist/esm/stories/ConnectWallet/useWalletDetailsModal.stories.js +109 -0
  20. package/dist/esm/stories/ConnectWallet/useWalletDetailsModal.stories.js.map +1 -0
  21. package/dist/esm/tokens/predict-address.js +36 -0
  22. package/dist/esm/tokens/predict-address.js.map +1 -0
  23. package/dist/esm/version.js +1 -1
  24. package/dist/esm/version.js.map +1 -1
  25. package/dist/types/exports/tokens.d.ts +1 -0
  26. package/dist/types/exports/tokens.d.ts.map +1 -1
  27. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  28. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +35 -0
  29. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  30. package/dist/types/stories/ConnectWallet/useWalletDetailsModal.stories.d.ts +23 -0
  31. package/dist/types/stories/ConnectWallet/useWalletDetailsModal.stories.d.ts.map +1 -0
  32. package/dist/types/tokens/predict-address.d.ts +3 -0
  33. package/dist/types/tokens/predict-address.d.ts.map +1 -0
  34. package/dist/types/tokens/types.d.ts +1 -1
  35. package/dist/types/version.d.ts +1 -1
  36. package/dist/types/version.d.ts.map +1 -1
  37. package/package.json +3 -3
  38. package/src/exports/tokens.ts +1 -0
  39. package/src/react/core/hooks/connection/ConnectButtonProps.ts +3 -0
  40. package/src/react/web/ui/ConnectWallet/Details.tsx +43 -0
  41. package/src/react/web/ui/ConnectWallet/screens/ViewAssets.tsx +2 -2
  42. package/src/stories/ConnectWallet/useWalletDetailsModal.stories.tsx +192 -0
  43. package/src/tokens/predict-address.ts +48 -0
  44. package/src/tokens/types.ts +1 -1
  45. package/src/version.ts +1 -1
@@ -179,6 +179,7 @@ export const ConnectedWalletDetails: React.FC<{
179
179
  supportedNFTs={props.supportedNFTs}
180
180
  supportedTokens={props.supportedTokens}
181
181
  theme={props.theme}
182
+ showBalanceInFiat={props.detailsButton?.showBalanceInFiat}
182
183
  />,
183
184
  );
184
185
  }
@@ -898,6 +899,7 @@ export function DetailsModal(props: {
898
899
  onBack={() => {
899
900
  setScreen("main");
900
901
  }}
902
+ manageWallet={props.detailsModal?.manageWallet}
901
903
  setScreen={setScreen}
902
904
  />
903
905
  );
@@ -975,6 +977,7 @@ export function DetailsModal(props: {
975
977
  client={client}
976
978
  hiddenWallets={props.detailsModal?.hiddenWallets}
977
979
  locale={locale.id}
980
+ connectOptions={props.connectOptions}
978
981
  onCancel={() => setScreen("main")}
979
982
  onSuccess={() => setScreen("main")}
980
983
  supportedTokens={props.supportedTokens}
@@ -1594,6 +1597,26 @@ export type UseWalletDetailsModalOptions = {
1594
1597
 
1595
1598
  /**
1596
1599
  * Render custom UI at the bottom of the Details Modal
1600
+ * @param props - props passed to the footer component which includes a function to close the modal
1601
+ * @example
1602
+ * ```tsx
1603
+ * function Example() {
1604
+ * const detailsModal = useWalletDetailsModal();
1605
+ *
1606
+ * return (
1607
+ * <button onClick={() => detailsModal.open({
1608
+ * client,
1609
+ * footer: CustomFooter,
1610
+ * })}>
1611
+ * wallet details
1612
+ * </button>
1613
+ * )
1614
+ * }
1615
+ *
1616
+ * function CustomFooter(props: { close: () => void }) {
1617
+ * return <div> ... </div>
1618
+ * }
1619
+ * ```
1597
1620
  */
1598
1621
  footer?: (props: { close: () => void }) => JSX.Element;
1599
1622
 
@@ -1653,6 +1676,11 @@ export type UseWalletDetailsModalOptions = {
1653
1676
  */
1654
1677
  hideBuyFunds?: boolean;
1655
1678
 
1679
+ /**
1680
+ * All wallet IDs included in this array will be hidden from wallet selection when connected.
1681
+ */
1682
+ hiddenWallets?: WalletId[];
1683
+
1656
1684
  /**
1657
1685
  * When you click on "View Assets", by default the "Tokens" tab is shown first.
1658
1686
  * If you want to show the "NFTs" tab first, change the order of the asset tabs to: ["nft", "token"]
@@ -1666,6 +1694,18 @@ export type UseWalletDetailsModalOptions = {
1666
1694
  */
1667
1695
  showBalanceInFiat?: SupportedFiatCurrency;
1668
1696
 
1697
+ /**
1698
+ * Configure options for managing the connected wallet.
1699
+ */
1700
+ manageWallet?: {
1701
+ /**
1702
+ * Allow linking other profiles to the connected wallet.
1703
+ *
1704
+ * By default it is `true`.
1705
+ */
1706
+ allowLinkingProfiles?: boolean;
1707
+ };
1708
+
1669
1709
  /**
1670
1710
  * The callback function for when the modal is closed
1671
1711
  * @param screen The name of the screen that was being shown when user closed the modal
@@ -1729,6 +1769,9 @@ export function useWalletDetailsModal() {
1729
1769
  closeModal={closeModal}
1730
1770
  connectOptions={props.connectOptions}
1731
1771
  detailsModal={{
1772
+ showBalanceInFiat: props.showBalanceInFiat,
1773
+ hiddenWallets: props.hiddenWallets,
1774
+ manageWallet: props.manageWallet,
1732
1775
  assetTabs: props.assetTabs,
1733
1776
  connectedAccountAvatarUrl: props.connectedAccountAvatarUrl,
1734
1777
  connectedAccountName: props.connectedAccountName,
@@ -22,7 +22,7 @@ export type AssetTabs = "token" | "nft";
22
22
 
23
23
  const TokenTab = {
24
24
  label: (
25
- <span className="flex gap-2">
25
+ <span style={{ display: "flex", gap: "8px", alignItems: "center" }}>
26
26
  <CoinsIcon size={iconSize.sm} /> Tokens
27
27
  </span>
28
28
  ),
@@ -31,7 +31,7 @@ const TokenTab = {
31
31
 
32
32
  const NftTab = {
33
33
  label: (
34
- <span className="flex gap-2">
34
+ <span style={{ display: "flex", gap: "8px", alignItems: "center" }}>
35
35
  <ImageIcon size={iconSize.sm} /> NFTs
36
36
  </span>
37
37
  ),
@@ -0,0 +1,192 @@
1
+ import type { Meta } from "@storybook/react-vite";
2
+ import { base } from "../../chains/chain-definitions/base.js";
3
+ import { ethereum } from "../../chains/chain-definitions/ethereum.js";
4
+ import { polygon } from "../../chains/chain-definitions/polygon.js";
5
+ import { lightTheme } from "../../react/core/design-system/index.js";
6
+ import { useActiveAccount } from "../../react/core/hooks/wallets/useActiveAccount.js";
7
+ import { ConnectButton } from "../../react/web/ui/ConnectWallet/ConnectButton.js";
8
+ import {
9
+ type UseWalletDetailsModalOptions,
10
+ useWalletDetailsModal,
11
+ } from "../../react/web/ui/ConnectWallet/Details.js";
12
+ import { storyClient } from "../utils.js";
13
+
14
+ const meta: Meta = {
15
+ parameters: {
16
+ layout: "centered",
17
+ },
18
+ tags: ["autodocs"],
19
+ title: "Hooks/useWalletDetailsModal",
20
+ decorators: [
21
+ (Story) => {
22
+ return (
23
+ <div style={{ display: "flex", flexDirection: "column", gap: "10px" }}>
24
+ <ConnectButton client={storyClient} autoConnect={true} />
25
+ <Story />
26
+ </div>
27
+ );
28
+ },
29
+ ],
30
+ };
31
+ export default meta;
32
+
33
+ export function BasicUsage() {
34
+ return <Variant client={storyClient} />;
35
+ }
36
+
37
+ export function DisableLinkingProfiles() {
38
+ return (
39
+ <Variant
40
+ client={storyClient}
41
+ manageWallet={{ allowLinkingProfiles: false }}
42
+ />
43
+ );
44
+ }
45
+
46
+ export function HideSwitchWallet() {
47
+ return <Variant client={storyClient} hideSwitchWallet={true} />;
48
+ }
49
+
50
+ export function HideDisconnect() {
51
+ return <Variant client={storyClient} hideDisconnect={true} />;
52
+ }
53
+
54
+ export function HideSendFunds() {
55
+ return <Variant client={storyClient} hideSendFunds={true} />;
56
+ }
57
+
58
+ export function HideReceiveFunds() {
59
+ return <Variant client={storyClient} hideReceiveFunds={true} />;
60
+ }
61
+
62
+ export function HideBuyFunds() {
63
+ return <Variant client={storyClient} hideBuyFunds={true} />;
64
+ }
65
+
66
+ export function HideAllTopButtons() {
67
+ return (
68
+ <Variant
69
+ client={storyClient}
70
+ hideSendFunds={true}
71
+ hideReceiveFunds={true}
72
+ hideBuyFunds={true}
73
+ />
74
+ );
75
+ }
76
+
77
+ export function Chains() {
78
+ return <Variant client={storyClient} chains={[ethereum, polygon, base]} />;
79
+ }
80
+
81
+ export function Locale() {
82
+ return <Variant client={storyClient} locale="ja_JP" />;
83
+ }
84
+
85
+ export function ConnectedAccountAvatarUrl() {
86
+ return (
87
+ <Variant
88
+ client={storyClient}
89
+ connectedAccountAvatarUrl="https://thirdweb.com/favicon.ico"
90
+ />
91
+ );
92
+ }
93
+
94
+ export function ConnectedAccountName() {
95
+ return <Variant client={storyClient} connectedAccountName="test" />;
96
+ }
97
+
98
+ export function ShowBalanceInFiat() {
99
+ return <Variant client={storyClient} showBalanceInFiat="usd" />;
100
+ }
101
+
102
+ export function AssetTabs() {
103
+ return <Variant client={storyClient} assetTabs={["nft", "token"]} />;
104
+ }
105
+
106
+ export function OnClose() {
107
+ return (
108
+ <Variant
109
+ client={storyClient}
110
+ onClose={() => {
111
+ alert("onClose");
112
+ }}
113
+ />
114
+ );
115
+ }
116
+
117
+ export function Footer() {
118
+ return (
119
+ <Variant
120
+ client={storyClient}
121
+ footer={(props) => (
122
+ <div
123
+ style={{
124
+ outline: "1px solid red",
125
+ padding: "16px",
126
+ display: "flex",
127
+ justifyContent: "space-between",
128
+ alignItems: "center",
129
+ gap: "10px",
130
+ }}
131
+ >
132
+ custom footer
133
+ <button onClick={props.close} type="button">
134
+ close
135
+ </button>
136
+ </div>
137
+ )}
138
+ />
139
+ );
140
+ }
141
+
142
+ export function ConnectOptions() {
143
+ return (
144
+ <Variant
145
+ client={storyClient}
146
+ connectOptions={{
147
+ showAllWallets: false,
148
+ }}
149
+ />
150
+ );
151
+ }
152
+
153
+ export function LightTheme() {
154
+ return <Variant client={storyClient} theme="light" />;
155
+ }
156
+
157
+ export function CustomLightTheme() {
158
+ return (
159
+ <Variant
160
+ client={storyClient}
161
+ theme={lightTheme({
162
+ colors: {
163
+ modalBg: "#FFFFF0",
164
+ tertiaryBg: "#DBE4C9",
165
+ borderColor: "#8AA624",
166
+ secondaryText: "#3E3F29",
167
+ accentText: "#E43636",
168
+ },
169
+ })}
170
+ />
171
+ );
172
+ }
173
+
174
+ function Variant(params: UseWalletDetailsModalOptions) {
175
+ const account = useActiveAccount();
176
+ const detailsModal = useWalletDetailsModal();
177
+
178
+ if (!account) {
179
+ return <p> no account </p>;
180
+ }
181
+
182
+ return (
183
+ <button
184
+ type="button"
185
+ onClick={() => {
186
+ detailsModal.open(params);
187
+ }}
188
+ >
189
+ test
190
+ </button>
191
+ );
192
+ }
@@ -0,0 +1,48 @@
1
+ import { bytesToHex, randomBytes } from "@noble/hashes/utils";
2
+ import type { Hex } from "viem";
3
+ import { predictAddress as _predictAddress } from "../extensions/tokens/__generated__/ERC20Entrypoint/read/predictAddress.js";
4
+ import { padHex, toHex } from "../utils/encoding/hex.js";
5
+ import { DEFAULT_DEVELOPER_ADDRESS } from "./constants.js";
6
+ import { getDeployedEntrypointERC20 } from "./get-entrypoint-erc20.js";
7
+ import {
8
+ encodeInitParams,
9
+ encodePoolConfig,
10
+ generateSalt,
11
+ } from "./token-utils.js";
12
+ import type { CreateTokenOptions } from "./types.js";
13
+
14
+ export async function predictAddress(options: CreateTokenOptions) {
15
+ const { client, account, params, launchConfig } = options;
16
+
17
+ const creator = params.owner || account.address;
18
+ const encodedInitData = await encodeInitParams({
19
+ client,
20
+ creator,
21
+ params,
22
+ });
23
+
24
+ const salt: Hex = generateSalt(options.salt || bytesToHex(randomBytes(31)));
25
+
26
+ const entrypoint = await getDeployedEntrypointERC20(options);
27
+
28
+ let hookData: Hex = "0x";
29
+ let contractId = padHex(toHex("ERC20Asset"), { size: 32 });
30
+ if (launchConfig?.kind === "pool") {
31
+ hookData = encodePoolConfig(launchConfig.config);
32
+ contractId = padHex(toHex("ERC20Asset_Pool"), { size: 32 });
33
+ }
34
+
35
+ const address = await _predictAddress({
36
+ contract: entrypoint,
37
+ contractId,
38
+ params: {
39
+ data: encodedInitData,
40
+ hookData,
41
+ developer: options.developerAddress || DEFAULT_DEVELOPER_ADDRESS,
42
+ salt,
43
+ },
44
+ creator,
45
+ });
46
+
47
+ return address;
48
+ }
@@ -22,7 +22,7 @@ export type PoolConfig = {
22
22
  };
23
23
 
24
24
  export type DistributeContent = {
25
- amount: bigint;
25
+ amount: string;
26
26
  recipient: string;
27
27
  };
28
28
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.105.34-nightly-92896ddf3f43cfa24d3b53d7b8b6c26f9b2b0c61-20250818000434";
1
+ export const version = "5.105.35";