thirdweb 5.78.0 → 5.79.0-nightly-f91f6310e9396918d0ffc5217eeb4a44cef0b8c8-20241215000412

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 (97) hide show
  1. package/dist/cjs/exports/react.js +8 -1
  2. package/dist/cjs/exports/react.js.map +1 -1
  3. package/dist/cjs/exports/wallets/in-app.js.map +1 -1
  4. package/dist/cjs/exports/wallets/in-app.native.js.map +1 -1
  5. package/dist/cjs/exports/wallets.js.map +1 -1
  6. package/dist/cjs/exports/wallets.native.js.map +1 -1
  7. package/dist/cjs/extensions/prebuilts/deploy-published.js +22 -16
  8. package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
  9. package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js +1 -1
  10. package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
  11. package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js +1 -1
  12. package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js.map +1 -1
  13. package/dist/cjs/react/web/ui/prebuilt/Chain/name.js +15 -11
  14. package/dist/cjs/react/web/ui/prebuilt/Chain/name.js.map +1 -1
  15. package/dist/cjs/react/web/ui/prebuilt/Chain/provider.js +1 -0
  16. package/dist/cjs/react/web/ui/prebuilt/Chain/provider.js.map +1 -1
  17. package/dist/cjs/react/web/ui/prebuilt/Wallet/icon.js +79 -0
  18. package/dist/cjs/react/web/ui/prebuilt/Wallet/icon.js.map +1 -0
  19. package/dist/cjs/react/web/ui/prebuilt/Wallet/name.js +105 -0
  20. package/dist/cjs/react/web/ui/prebuilt/Wallet/name.js.map +1 -0
  21. package/dist/cjs/react/web/ui/prebuilt/Wallet/provider.js +47 -0
  22. package/dist/cjs/react/web/ui/prebuilt/Wallet/provider.js.map +1 -0
  23. package/dist/cjs/version.js +1 -1
  24. package/dist/cjs/version.js.map +1 -1
  25. package/dist/esm/exports/react.js +4 -0
  26. package/dist/esm/exports/react.js.map +1 -1
  27. package/dist/esm/exports/wallets/in-app.js.map +1 -1
  28. package/dist/esm/exports/wallets/in-app.native.js.map +1 -1
  29. package/dist/esm/exports/wallets.js.map +1 -1
  30. package/dist/esm/exports/wallets.native.js.map +1 -1
  31. package/dist/esm/extensions/prebuilts/deploy-published.js +22 -16
  32. package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
  33. package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js +1 -1
  34. package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
  35. package/dist/esm/react/web/ui/prebuilt/Chain/icon.js +1 -1
  36. package/dist/esm/react/web/ui/prebuilt/Chain/icon.js.map +1 -1
  37. package/dist/esm/react/web/ui/prebuilt/Chain/name.js +14 -11
  38. package/dist/esm/react/web/ui/prebuilt/Chain/name.js.map +1 -1
  39. package/dist/esm/react/web/ui/prebuilt/Chain/provider.js +1 -0
  40. package/dist/esm/react/web/ui/prebuilt/Chain/provider.js.map +1 -1
  41. package/dist/esm/react/web/ui/prebuilt/Wallet/icon.js +75 -0
  42. package/dist/esm/react/web/ui/prebuilt/Wallet/icon.js.map +1 -0
  43. package/dist/esm/react/web/ui/prebuilt/Wallet/name.js +100 -0
  44. package/dist/esm/react/web/ui/prebuilt/Wallet/name.js.map +1 -0
  45. package/dist/esm/react/web/ui/prebuilt/Wallet/provider.js +42 -0
  46. package/dist/esm/react/web/ui/prebuilt/Wallet/provider.js.map +1 -0
  47. package/dist/esm/version.js +1 -1
  48. package/dist/esm/version.js.map +1 -1
  49. package/dist/types/exports/react.d.ts +3 -0
  50. package/dist/types/exports/react.d.ts.map +1 -1
  51. package/dist/types/exports/wallets/in-app.d.ts +2 -1
  52. package/dist/types/exports/wallets/in-app.d.ts.map +1 -1
  53. package/dist/types/exports/wallets/in-app.native.d.ts +2 -1
  54. package/dist/types/exports/wallets/in-app.native.d.ts.map +1 -1
  55. package/dist/types/exports/wallets.d.ts +2 -1
  56. package/dist/types/exports/wallets.d.ts.map +1 -1
  57. package/dist/types/exports/wallets.native.d.ts +2 -1
  58. package/dist/types/exports/wallets.native.d.ts.map +1 -1
  59. package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
  60. package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts +10 -1
  61. package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts.map +1 -1
  62. package/dist/types/react/web/ui/prebuilt/Chain/provider.d.ts +1 -0
  63. package/dist/types/react/web/ui/prebuilt/Chain/provider.d.ts.map +1 -1
  64. package/dist/types/react/web/ui/prebuilt/Wallet/icon.d.ts +81 -0
  65. package/dist/types/react/web/ui/prebuilt/Wallet/icon.d.ts.map +1 -0
  66. package/dist/types/react/web/ui/prebuilt/Wallet/name.d.ts +111 -0
  67. package/dist/types/react/web/ui/prebuilt/Wallet/name.d.ts.map +1 -0
  68. package/dist/types/react/web/ui/prebuilt/Wallet/provider.d.ts +41 -0
  69. package/dist/types/react/web/ui/prebuilt/Wallet/provider.d.ts.map +1 -0
  70. package/dist/types/version.d.ts +1 -1
  71. package/dist/types/version.d.ts.map +1 -1
  72. package/dist/types/wallets/in-app/core/wallet/types.d.ts +3 -3
  73. package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
  74. package/package.json +3 -2
  75. package/src/exports/react.ts +14 -0
  76. package/src/exports/wallets/in-app.native.ts +6 -0
  77. package/src/exports/wallets/in-app.ts +6 -0
  78. package/src/exports/wallets.native.ts +6 -0
  79. package/src/exports/wallets.ts +6 -0
  80. package/src/extensions/prebuilts/deploy-published.ts +27 -20
  81. package/src/react/core/hooks/wallets/useAddConnectedWallet.test.tsx +52 -0
  82. package/src/react/core/hooks/wallets/useConnect.test.tsx +105 -0
  83. package/src/react/core/hooks/wallets/useSetActiveWallet.test.tsx +53 -0
  84. package/src/react/web/ui/MediaRenderer/useResolvedMediaType.ts +1 -1
  85. package/src/react/web/ui/prebuilt/Chain/icon.tsx +1 -1
  86. package/src/react/web/ui/prebuilt/Chain/name.test.tsx +19 -1
  87. package/src/react/web/ui/prebuilt/Chain/name.tsx +19 -13
  88. package/src/react/web/ui/prebuilt/Chain/provider.tsx +1 -0
  89. package/src/react/web/ui/prebuilt/Wallet/icon.test.tsx +30 -0
  90. package/src/react/web/ui/prebuilt/Wallet/icon.tsx +120 -0
  91. package/src/react/web/ui/prebuilt/Wallet/name.test.tsx +55 -0
  92. package/src/react/web/ui/prebuilt/Wallet/name.tsx +164 -0
  93. package/src/react/web/ui/prebuilt/Wallet/provider.test.tsx +61 -0
  94. package/src/react/web/ui/prebuilt/Wallet/provider.tsx +65 -0
  95. package/src/version.ts +1 -1
  96. package/src/wallets/in-app/core/wallet/types.ts +7 -8
  97. package/src/wallets/manager/connection-manager.test.ts +133 -133
@@ -0,0 +1,81 @@
1
+ import { type UseQueryOptions } from "@tanstack/react-query";
2
+ import type { JSX } from "react";
3
+ import type { WalletId } from "../../../../../wallets/wallet-types.js";
4
+ export interface WalletIconProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> {
5
+ /**
6
+ * This component will be shown while the icon of the wallet is being fetched
7
+ * If not passed, the component will return `null`.
8
+ *
9
+ * You can/should pass a loading sign or spinner to this prop.
10
+ * @example
11
+ * ```tsx
12
+ * <WalletIcon loadingComponent={<Spinner />} />
13
+ * ```
14
+ */
15
+ loadingComponent?: JSX.Element;
16
+ /**
17
+ * This component will be shown if the icon fails to be retreived
18
+ * If not passed, the component will return `null`.
19
+ *
20
+ * You can/should pass a descriptive text/component to this prop, indicating that the
21
+ * icon was not fetched succesfully
22
+ * @example
23
+ * ```tsx
24
+ * <WalletIcon fallbackComponent={<span>Failed to load</span>}
25
+ * />
26
+ * ```
27
+ */
28
+ fallbackComponent?: JSX.Element;
29
+ /**
30
+ * Optional `useQuery` params
31
+ */
32
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
33
+ }
34
+ /**
35
+ * This component tries to resolve the icon of a given wallet, then return an image.
36
+ * @returns an <img /> with the src of the wallet icon
37
+ *
38
+ * @example
39
+ * ### Basic usage
40
+ * ```tsx
41
+ * import { WalletProvider, WalletIcon } from "thirdweb/react";
42
+ *
43
+ * <WalletProvider id="io.metamask">
44
+ * <WalletIcon />
45
+ * </WalletProvider>
46
+ * ```
47
+ *
48
+ * Result: An <img /> component with the src of the icon
49
+ * ```html
50
+ * <img src="metamask-icon.png" />
51
+ * ```
52
+ *
53
+ * ### Show a loading sign while the icon is being loaded
54
+ * ```tsx
55
+ * <WalletIcon loadingComponent={<Spinner />} />
56
+ * ```
57
+ *
58
+ * ### Fallback to a dummy image if the wallet icon fails to resolve
59
+ * ```tsx
60
+ * <WalletIcon fallbackComponent={<img src="blank-image.png" />} />
61
+ * ```
62
+ *
63
+ * ### Usage with queryOptions
64
+ * WalletIcon uses useQuery() from tanstack query internally.
65
+ * It allows you to pass a custom queryOptions of your choice for more control of the internal fetching logic
66
+ * ```tsx
67
+ * <WalletIcon queryOptions={{ enabled: someLogic, retry: 3, }} />
68
+ * ```
69
+ *
70
+ * @component
71
+ * @wallet
72
+ * @beta
73
+ */
74
+ export declare function WalletIcon({ loadingComponent, fallbackComponent, queryOptions, ...restProps }: WalletIconProps): import("react/jsx-runtime.js").JSX.Element | null;
75
+ /**
76
+ * @internal Exported for tests only
77
+ */
78
+ export declare function fetchWalletImage(props: {
79
+ id: WalletId;
80
+ }): Promise<string>;
81
+ //# sourceMappingURL=icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Wallet/icon.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAGvE,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAC9D;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU,CAAC,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,GAAG,SAAS,EACb,EAAE,eAAe,qDASjB;AAiBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,EAAE,EAAE,QAAQ,CAAC;CACd,mBAGA"}
@@ -0,0 +1,111 @@
1
+ import { type UseQueryOptions } from "@tanstack/react-query";
2
+ import type { JSX } from "react";
3
+ import type { WalletId } from "../../../../../wallets/wallet-types.js";
4
+ /**
5
+ * Props for the WalletName component
6
+ * @component
7
+ * @wallet
8
+ */
9
+ export interface WalletNameProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
10
+ /**
11
+ * This component will be shown while the name of the wallet name is being fetched
12
+ * If not passed, the component will return `null`.
13
+ *
14
+ * You can/should pass a loading sign or spinner to this prop.
15
+ * @example
16
+ * ```tsx
17
+ * <WalletName loadingComponent={<Spinner />} />
18
+ * ```
19
+ */
20
+ loadingComponent?: JSX.Element;
21
+ /**
22
+ * This component will be shown if the name fails to be retreived
23
+ * If not passed, the component will return `null`.
24
+ *
25
+ * You can/should pass a descriptive text/component to this prop, indicating that the
26
+ * name was not fetched succesfully
27
+ * @example
28
+ * ```tsx
29
+ * <WalletName fallbackComponent={<span>Failed to load</span>}
30
+ * />
31
+ * ```
32
+ */
33
+ fallbackComponent?: JSX.Element;
34
+ /**
35
+ * Optional `useQuery` params
36
+ */
37
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
38
+ /**
39
+ * A function to format the name's display value
40
+ * ```tsx
41
+ * <WalletName formatFn={(str: string) => doSomething()} />
42
+ * ```
43
+ */
44
+ formatFn?: (str: string) => string;
45
+ }
46
+ /**
47
+ * This component fetches then shows the name of a wallet.
48
+ * It inherits all the attributes of a HTML <span> component, hence you can style it just like how you would style a normal <span>
49
+ *
50
+ * @example
51
+ * ### Basic usage
52
+ * ```tsx
53
+ * import { WalletProvider, WalletName } from "thirdweb/react";
54
+ *
55
+ * <WalletProvider id="io.metamask">
56
+ * <WalletName />
57
+ * </WalletProvider>
58
+ * ```
59
+ * Result:
60
+ * ```html
61
+ * <span>MetaMask</span>
62
+ * ```
63
+ *
64
+ * ### Show a loading sign when the name is being fetched
65
+ * ```tsx
66
+ * import { WalletProvider, WalletName } from "thirdweb/react";
67
+ *
68
+ * <WalletProvider {...props}>
69
+ * <WalletName loadingComponent={<Spinner />} />
70
+ * </WalletProvider>
71
+ * ```
72
+ *
73
+ * ### Fallback to something when the name fails to resolve
74
+ * ```tsx
75
+ * <WalletProvider {...props}>
76
+ * <WalletName fallbackComponent={<span>Failed to load</span>} />
77
+ * </WalletProvider>
78
+ * ```
79
+ *
80
+ * ### Custom query options for useQuery
81
+ * This component uses `@tanstack-query`'s useQuery internally.
82
+ * You can use the `queryOptions` prop for more fine-grained control
83
+ * ```tsx
84
+ * <WalletName
85
+ * queryOptions={{
86
+ * enabled: isEnabled,
87
+ * retry: 4,
88
+ * }}
89
+ * />
90
+ * @component
91
+ * @beta
92
+ * @wallet
93
+ */
94
+ export declare function WalletName({ loadingComponent, fallbackComponent, queryOptions, formatFn, ...restProps }: WalletNameProps): import("react/jsx-runtime.js").JSX.Element | null;
95
+ /**
96
+ * @internal Exported for tests only
97
+ */
98
+ export declare function getQueryKeys(props: {
99
+ id: WalletId;
100
+ formatFn?: (str: string) => string;
101
+ }): readonly ["walletName", WalletId] | readonly ["walletName", WalletId, {
102
+ readonly resolver: string;
103
+ }];
104
+ /**
105
+ * @internal Exported for tests only
106
+ */
107
+ export declare function fetchWalletName(props: {
108
+ id: WalletId;
109
+ formatFn?: (str: string) => string;
110
+ }): Promise<string>;
111
+ //# sourceMappingURL=name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Wallet/name.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAGvE;;;;GAIG;AACH,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC/D;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;IACrE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,UAAU,CAAC,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,eAAe,qDASjB;AAkBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;;GASA;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,mBAMA"}
@@ -0,0 +1,41 @@
1
+ import type React from "react";
2
+ import type { WalletId } from "../../../../../wallets/wallet-types.js";
3
+ /**
4
+ * Props for the WalletProvider component
5
+ * @component
6
+ * @wallet
7
+ */
8
+ export type WalletProviderProps = {
9
+ id: WalletId;
10
+ };
11
+ /**
12
+ * @internal Exported for tests only
13
+ */
14
+ export declare const WalletProviderContext: React.Context<WalletProviderProps | undefined>;
15
+ /**
16
+ /**
17
+ * A React context provider component that supplies Wallet-related data to its child components.
18
+ *
19
+ * This component serves as a wrapper around the `WalletProviderContext.Provider` and passes
20
+ * the provided wallet data down to all of its child components through the context API.
21
+ *
22
+ * @example
23
+ * ### Basic usage
24
+ * ```tsx
25
+ * import { WalletProvider, WalletIcon, WalletName } from "thirdweb/react";
26
+ *
27
+ * <WalletProvider id="io.metamask">
28
+ * <WalletIcon />
29
+ * <WalletName />
30
+ * </WalletProvider>
31
+ * ```
32
+ * @beta
33
+ * @component
34
+ * @wallet
35
+ */
36
+ export declare function WalletProvider(props: React.PropsWithChildren<WalletProviderProps>): import("react/jsx-runtime.js").JSX.Element;
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare function useWalletContext(): WalletProviderProps;
41
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Wallet/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,QAAQ,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,gDAEtB,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,8CAOpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,wBAQ/B"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.78.0";
1
+ export declare const version = "5.79.0-nightly-f91f6310e9396918d0ffc5217eeb4a44cef0b8c8-20241215000412";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { Chain } from "../../../../chains/types.js";
2
2
  import type { ThirdwebClient } from "../../../../client/client.js";
3
3
  import type { SupportedSmsCountry } from "../../../../react/web/wallets/in-app/supported-sms-countries.js";
4
+ import type { Prettify } from "../../../../utils/type-utils.js";
4
5
  import type { SmartWalletOptions } from "../../../smart/types.js";
5
6
  import type { AuthOption, OAuthOption, SocialAuthOption } from "../../../types.js";
6
7
  import type { EcosystemWalletId } from "../../../wallet-types.js";
@@ -10,11 +11,10 @@ export type Ecosystem = {
10
11
  id: EcosystemWalletId;
11
12
  partnerId?: string;
12
13
  };
13
- export type InAppWalletConnectionOptions = (MultiStepAuthArgsType | SingleStepAuthArgsType) & {
14
+ export type InAppWalletConnectionOptions = Prettify<(MultiStepAuthArgsType | SingleStepAuthArgsType) & {
14
15
  client: ThirdwebClient;
15
16
  chain?: Chain;
16
- redirect?: boolean;
17
- };
17
+ }>;
18
18
  export type InAppWalletAutoConnectOptions = {
19
19
  client: ThirdwebClient;
20
20
  authResult?: AuthStoredTokenWithCookieReturnType;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iEAAiE,CAAC;AAC3G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EACV,mCAAmC,EACnC,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,iBAAiB,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACvC,qBAAqB,GACrB,sBAAsB,CACzB,GAAG;IACF,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,mCAAmC,CAAC;IACjD,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AACrD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC;AAEzC,MAAM,MAAM,0BAA0B,GAClC;IACE,IAAI,CAAC,EAAE;QACL;;WAEG;QACH,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B;;WAEG;QACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;QACvC;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;WAEG;QACH,qBAAqB,CAAC,EAAE,mBAAmB,CAAC;KAC7C,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE;YACN,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;IACF;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;QAEI;IACJ,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACD,SAAS,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iEAAiE,CAAC;AAC3G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EACV,mCAAmC,EACnC,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,iBAAiB,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CACjD,CAAC,qBAAqB,GAAG,sBAAsB,CAAC,GAAG;IACjD,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CACF,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,mCAAmC,CAAC;IACjD,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AACrD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC;AAEzC,MAAM,MAAM,0BAA0B,GAClC;IACE,IAAI,CAAC,EAAE;QACL;;WAEG;QACH,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B;;WAEG;QACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;QACvC;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;WAEG;QACH,qBAAqB,CAAC,EAAE,mBAAmB,CAAC;KAC7C,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE;YACN,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;IACF;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;QAEI;IACJ,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACD,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.78.0",
3
+ "version": "5.79.0-nightly-f91f6310e9396918d0ffc5217eeb4a44cef0b8c8-20241215000412",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -340,6 +340,7 @@
340
340
  "size-limit": "11.1.6",
341
341
  "storybook": "8.4.7",
342
342
  "typedoc": "0.27.4",
343
+ "typedoc-better-json": "0.9.4",
343
344
  "typescript": "5.7.2",
344
345
  "vite": "6.0.3",
345
346
  "vitest": "2.1.8"
@@ -368,7 +369,7 @@
368
369
  "test:ui": "vitest dev -c ./test/vitest.config.ts --coverage --ui",
369
370
  "test:dev": "vitest run -c ./test/vitest.config.ts",
370
371
  "test:react": "vitest run -c ./test/vitest.config.ts dev --ui src/react",
371
- "typedoc": "bun run scripts/typedoc.mjs",
372
+ "typedoc": "node scripts/typedoc.mjs && node scripts/parse.mjs",
372
373
  "update-version": "node scripts/version.mjs",
373
374
  "storybook": "storybook dev -p 6006",
374
375
  "build-storybook": "storybook build"
@@ -273,3 +273,17 @@ export {
273
273
 
274
274
  // Utils
275
275
  export { getLastAuthProvider } from "../react/web/utils/storage.js";
276
+
277
+ // Wallet
278
+ export {
279
+ WalletProvider,
280
+ type WalletProviderProps,
281
+ } from "../react/web/ui/prebuilt/Wallet/provider.js";
282
+ export {
283
+ WalletIcon,
284
+ type WalletIconProps,
285
+ } from "../react/web/ui/prebuilt/Wallet/icon.js";
286
+ export {
287
+ WalletName,
288
+ type WalletNameProps,
289
+ } from "../react/web/ui/prebuilt/Wallet/name.js";
@@ -18,6 +18,12 @@ export type {
18
18
  InAppWalletAuth,
19
19
  InAppWalletSocialAuth,
20
20
  InAppWalletConnectionOptions,
21
+ InAppWalletAutoConnectOptions,
21
22
  } from "../../wallets/in-app/core/wallet/types.js";
22
23
 
24
+ export type {
25
+ MultiStepAuthArgsType,
26
+ SingleStepAuthArgsType,
27
+ } from "../../wallets/in-app/core/authentication/types.js";
28
+
23
29
  export { hasStoredPasskey } from "../../wallets/in-app/native/auth/passkeys.js";
@@ -18,8 +18,14 @@ export type {
18
18
  InAppWalletAuth,
19
19
  InAppWalletSocialAuth,
20
20
  InAppWalletConnectionOptions,
21
+ InAppWalletAutoConnectOptions,
21
22
  } from "../../wallets/in-app/core/wallet/types.js";
22
23
 
24
+ export type {
25
+ MultiStepAuthArgsType,
26
+ SingleStepAuthArgsType,
27
+ } from "../../wallets/in-app/core/authentication/types.js";
28
+
23
29
  export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";
24
30
 
25
31
  export {
@@ -89,8 +89,14 @@ export type {
89
89
  * @deprecated use InAppWalletSocialAuth instead
90
90
  */
91
91
  InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
92
+ InAppWalletCreationOptions,
92
93
  } from "../wallets/in-app/core/wallet/types.js";
93
94
 
95
+ export type {
96
+ MultiStepAuthArgsType,
97
+ SingleStepAuthArgsType,
98
+ } from "../wallets/in-app/core/authentication/types.js";
99
+
94
100
  export {
95
101
  preAuthenticate,
96
102
  authenticate,
@@ -96,8 +96,14 @@ export type {
96
96
  * @deprecated use InAppWalletSocialAuth instead
97
97
  */
98
98
  InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
99
+ InAppWalletCreationOptions,
99
100
  } from "../wallets/in-app/core/wallet/types.js";
100
101
 
102
+ export type {
103
+ MultiStepAuthArgsType,
104
+ SingleStepAuthArgsType,
105
+ } from "../wallets/in-app/core/authentication/types.js";
106
+
101
107
  export {
102
108
  preAuthenticate,
103
109
  authenticate,
@@ -150,28 +150,35 @@ export async function deployContractfromDeployMetadata(
150
150
  salt,
151
151
  } = options;
152
152
 
153
- const processedImplParams: Record<string, string | string[]> = {};
154
- for (const key in implementationConstructorParams) {
155
- processedImplParams[key] = await processRefDeployments({
156
- client,
157
- account,
158
- chain,
159
- paramValue: implementationConstructorParams[key] as
160
- | string
161
- | ImplementationConstructorParam,
162
- });
153
+ let processedImplParams: Record<string, string | string[]> | undefined;
154
+ let processedInitializeParams: Record<string, string | string[]> | undefined;
155
+
156
+ if (implementationConstructorParams) {
157
+ processedImplParams = {};
158
+ for (const key in implementationConstructorParams) {
159
+ processedImplParams[key] = await processRefDeployments({
160
+ client,
161
+ account,
162
+ chain,
163
+ paramValue: implementationConstructorParams[key] as
164
+ | string
165
+ | ImplementationConstructorParam,
166
+ });
167
+ }
163
168
  }
164
169
 
165
- const processedInitializeParams: Record<string, string | string[]> = {};
166
- for (const key in initializeParams) {
167
- processedInitializeParams[key] = await processRefDeployments({
168
- client,
169
- account,
170
- chain,
171
- paramValue: initializeParams[key] as
172
- | string
173
- | ImplementationConstructorParam,
174
- });
170
+ if (initializeParams) {
171
+ processedInitializeParams = {};
172
+ for (const key in initializeParams) {
173
+ processedInitializeParams[key] = await processRefDeployments({
174
+ client,
175
+ account,
176
+ chain,
177
+ paramValue: initializeParams[key] as
178
+ | string
179
+ | ImplementationConstructorParam,
180
+ });
181
+ }
175
182
  }
176
183
 
177
184
  switch (deployMetadata?.deployType) {
@@ -0,0 +1,52 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import type { ReactNode } from "react";
3
+ import { describe, expect, it } from "vitest";
4
+ import { MockStorage } from "../../../../../test/src/mocks/storage.js";
5
+ import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
6
+ import { TEST_ACCOUNT_A } from "../../../../../test/src/test-wallets.js";
7
+ import { createWalletAdapter } from "../../../../adapters/wallet-adapter.js";
8
+ import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
9
+ import { createConnectionManager } from "../../../../wallets/manager/index.js";
10
+ import { ConnectionManagerCtx } from "../../providers/connection-manager.js";
11
+ import { useAddConnectedWallet } from "./useAddConnectedWallet.js";
12
+
13
+ describe("useAddConnectedWallet", () => {
14
+ // Mock the connection manager
15
+ const mockStorage = new MockStorage();
16
+ const manager = createConnectionManager(mockStorage);
17
+
18
+ // Create a wrapper component with the mocked context
19
+ const wrapper = ({ children }: { children: ReactNode }) => {
20
+ return (
21
+ <ConnectionManagerCtx.Provider value={manager}>
22
+ {children}
23
+ </ConnectionManagerCtx.Provider>
24
+ );
25
+ };
26
+
27
+ const wallet = createWalletAdapter({
28
+ adaptedAccount: TEST_ACCOUNT_A,
29
+ client: TEST_CLIENT,
30
+ chain: ethereum,
31
+ onDisconnect: () => {},
32
+ switchChain: () => {},
33
+ });
34
+
35
+ it("should add a wallet to the connection manager", async () => {
36
+ // Render the hook
37
+ const { result } = renderHook(() => useAddConnectedWallet(), { wrapper });
38
+ result.current(wallet);
39
+
40
+ expect(manager.connectedWallets.getValue()).toHaveLength(1);
41
+ expect(manager.connectedWallets.getValue()[0]).toEqual(wallet);
42
+ // add connected wallet should not set the active wallet
43
+ expect(manager.activeWalletStore.getValue()).toBeUndefined();
44
+ });
45
+
46
+ it("should throw an error when used outside of ThirdwebProvider", () => {
47
+ // Render the hook without a provider
48
+ expect(() => {
49
+ renderHook(() => useAddConnectedWallet());
50
+ }).toThrow("useAddConnectedWallet must be used within <ThirdwebProvider>");
51
+ });
52
+ });
@@ -0,0 +1,105 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import type { ReactNode } from "react";
3
+ import { beforeEach, describe, expect, it } from "vitest";
4
+ import { MockStorage } from "../../../../../test/src/mocks/storage.js";
5
+ import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
6
+ import { TEST_ACCOUNT_A } from "../../../../../test/src/test-wallets.js";
7
+ import { createWalletAdapter } from "../../../../adapters/wallet-adapter.js";
8
+ import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
9
+ import {
10
+ type ConnectionManager,
11
+ createConnectionManager,
12
+ } from "../../../../wallets/manager/index.js";
13
+ import { ConnectionManagerCtx } from "../../providers/connection-manager.js";
14
+ import { useActiveWalletConnectionStatus } from "./useActiveWalletConnectionStatus.js";
15
+ import { useConnect } from "./useConnect.js";
16
+
17
+ describe("useAddConnectedWallet", () => {
18
+ // Mock the connection manager
19
+ const mockStorage = new MockStorage();
20
+ let manager: ConnectionManager;
21
+
22
+ // Create a wrapper component with the mocked context
23
+ const wrapper = ({ children }: { children: ReactNode }) => {
24
+ return (
25
+ <ConnectionManagerCtx.Provider value={manager}>
26
+ {children}
27
+ </ConnectionManagerCtx.Provider>
28
+ );
29
+ };
30
+
31
+ const wallet = createWalletAdapter({
32
+ adaptedAccount: TEST_ACCOUNT_A,
33
+ client: TEST_CLIENT,
34
+ chain: ethereum,
35
+ onDisconnect: () => {},
36
+ switchChain: () => {},
37
+ });
38
+
39
+ beforeEach(() => {
40
+ manager = createConnectionManager(mockStorage);
41
+ });
42
+
43
+ it("should connect a wallet to the connection manager", async () => {
44
+ const { result: statusResult } = renderHook(
45
+ () => useActiveWalletConnectionStatus(),
46
+ {
47
+ wrapper,
48
+ },
49
+ );
50
+ const { result } = renderHook(() => useConnect(), { wrapper });
51
+ expect(statusResult.current).toEqual("disconnected");
52
+ await result.current.connect(async () => wallet);
53
+ expect(statusResult.current).toEqual("connected");
54
+
55
+ // should add to connected wallets
56
+ expect(manager.connectedWallets.getValue()).toHaveLength(1);
57
+ expect(manager.connectedWallets.getValue()[0]).toEqual(wallet);
58
+ // should set the active wallet
59
+ expect(manager.activeWalletStore.getValue()).toEqual(wallet);
60
+ });
61
+
62
+ it("should handle a function that returns a wallet", async () => {
63
+ const { result: statusResult } = renderHook(
64
+ () => useActiveWalletConnectionStatus(),
65
+ {
66
+ wrapper,
67
+ },
68
+ );
69
+ const { result } = renderHook(() => useConnect(), { wrapper });
70
+ expect(statusResult.current).toEqual("disconnected");
71
+ await result.current.connect(async () => wallet);
72
+ expect(statusResult.current).toEqual("connected");
73
+
74
+ // should add to connected wallets
75
+ expect(manager.connectedWallets.getValue()).toHaveLength(1);
76
+ expect(manager.connectedWallets.getValue()[0]).toEqual(wallet);
77
+ // should set the active wallet
78
+ expect(manager.activeWalletStore.getValue()).toEqual(wallet);
79
+ });
80
+
81
+ it("should handle an error when connecting a wallet", async () => {
82
+ const { result: statusResult } = renderHook(
83
+ () => useActiveWalletConnectionStatus(),
84
+ {
85
+ wrapper,
86
+ },
87
+ );
88
+ expect(statusResult.current).toEqual("disconnected");
89
+ const { result } = renderHook(() => useConnect(), { wrapper });
90
+ await result.current.connect(async () => {
91
+ throw new Error("test");
92
+ });
93
+
94
+ expect(statusResult.current).toEqual("disconnected");
95
+ // should set the active wallet
96
+ expect(manager.activeWalletStore.getValue()).toEqual(undefined);
97
+ });
98
+
99
+ it("should throw an error when used outside of ThirdwebProvider", () => {
100
+ // Render the hook without a provider
101
+ expect(() => {
102
+ renderHook(() => useConnect());
103
+ }).toThrow("useConnect must be used within <ThirdwebProvider>");
104
+ });
105
+ });
@@ -0,0 +1,53 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import type { ReactNode } from "react";
3
+ import { describe, expect, it } from "vitest";
4
+ import { MockStorage } from "../../../../../test/src/mocks/storage.js";
5
+ import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
6
+ import { TEST_ACCOUNT_A } from "../../../../../test/src/test-wallets.js";
7
+ import { createWalletAdapter } from "../../../../adapters/wallet-adapter.js";
8
+ import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
9
+ import { createConnectionManager } from "../../../../wallets/manager/index.js";
10
+ import { ConnectionManagerCtx } from "../../providers/connection-manager.js";
11
+ import { useSetActiveWallet } from "./useSetActiveWallet.js";
12
+
13
+ describe("useAddConnectedWallet", () => {
14
+ // Mock the connection manager
15
+ const mockStorage = new MockStorage();
16
+ const manager = createConnectionManager(mockStorage);
17
+
18
+ // Create a wrapper component with the mocked context
19
+ const wrapper = ({ children }: { children: ReactNode }) => {
20
+ return (
21
+ <ConnectionManagerCtx.Provider value={manager}>
22
+ {children}
23
+ </ConnectionManagerCtx.Provider>
24
+ );
25
+ };
26
+
27
+ const wallet = createWalletAdapter({
28
+ adaptedAccount: TEST_ACCOUNT_A,
29
+ client: TEST_CLIENT,
30
+ chain: ethereum,
31
+ onDisconnect: () => {},
32
+ switchChain: () => {},
33
+ });
34
+
35
+ it("should add a wallet to the connection manager", async () => {
36
+ // Render the hook
37
+ const { result } = renderHook(() => useSetActiveWallet(), { wrapper });
38
+ result.current(wallet);
39
+
40
+ // should add to connected wallets
41
+ expect(manager.connectedWallets.getValue()).toHaveLength(1);
42
+ expect(manager.connectedWallets.getValue()[0]).toEqual(wallet);
43
+ // should set the active wallet
44
+ expect(manager.activeWalletStore.getValue()).toEqual(wallet);
45
+ });
46
+
47
+ it("should throw an error when used outside of ThirdwebProvider", () => {
48
+ // Render the hook without a provider
49
+ expect(() => {
50
+ renderHook(() => useSetActiveWallet());
51
+ }).toThrow("useSetActiveWallet must be used within <ThirdwebProvider>");
52
+ });
53
+ });