thirdweb 5.42.0-nightly-e27ebef85bb61342c3de53f85e134cf4a29f787c-20240730000342 → 5.42.0
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.
- package/dist/cjs/adapters/wallet-adapter.js +12 -1
- package/dist/cjs/adapters/wallet-adapter.js.map +1 -1
- package/dist/cjs/exports/wallets/in-app.js.map +1 -1
- package/dist/cjs/exports/wallets.js.map +1 -1
- package/dist/cjs/exports/wallets.native.js.map +1 -1
- package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js +5 -0
- package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +196 -2
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +109 -3
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +19 -7
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/create-wallet.js +73 -0
- package/dist/cjs/wallets/create-wallet.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/ecosystem.js +29 -3
- package/dist/cjs/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/in-app.js +100 -5
- package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +71 -5
- package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/esm/adapters/wallet-adapter.js +12 -1
- package/dist/esm/adapters/wallet-adapter.js.map +1 -1
- package/dist/esm/exports/wallets/in-app.js.map +1 -1
- package/dist/esm/exports/wallets.js.map +1 -1
- package/dist/esm/exports/wallets.native.js.map +1 -1
- package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js +5 -0
- package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +196 -2
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +109 -3
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +19 -7
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/create-wallet.js +73 -0
- package/dist/esm/wallets/create-wallet.js.map +1 -1
- package/dist/esm/wallets/in-app/web/ecosystem.js +29 -3
- package/dist/esm/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/esm/wallets/in-app/web/in-app.js +100 -5
- package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +71 -5
- package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/types/adapters/wallet-adapter.d.ts +12 -1
- package/dist/types/adapters/wallet-adapter.d.ts.map +1 -1
- package/dist/types/exports/wallets/in-app.d.ts +1 -0
- package/dist/types/exports/wallets/in-app.d.ts.map +1 -1
- package/dist/types/exports/wallets.d.ts +4 -2
- package/dist/types/exports/wallets.d.ts.map +1 -1
- package/dist/types/exports/wallets.native.d.ts +3 -2
- package/dist/types/exports/wallets.native.d.ts.map +1 -1
- package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts +5 -0
- package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts +196 -2
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts +109 -3
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/create-wallet.d.ts +73 -0
- package/dist/types/wallets/create-wallet.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/types.d.ts +5 -4
- package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/ecosystem.d.ts +29 -3
- package/dist/types/wallets/in-app/web/ecosystem.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/in-app.d.ts +100 -5
- package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts +71 -5
- package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/wallet-adapter.ts +12 -1
- package/src/exports/wallets/in-app.ts +6 -0
- package/src/exports/wallets.native.ts +8 -1
- package/src/exports/wallets.ts +13 -1
- package/src/react/web/ui/AutoConnect/AutoConnect.tsx +5 -0
- package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +196 -2
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +109 -3
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +19 -8
- package/src/version.ts +1 -1
- package/src/wallets/create-wallet.ts +73 -0
- package/src/wallets/ecosystem/types.ts +9 -5
- package/src/wallets/in-app/web/ecosystem.ts +29 -3
- package/src/wallets/in-app/web/in-app.ts +100 -5
- package/src/wallets/smart/smart-wallet.ts +71 -5
@@ -40,21 +40,127 @@ import { ConnectModalContent } from "./ConnectModalContent.js";
|
|
40
40
|
import { useSetupScreen } from "./screen.js";
|
41
41
|
|
42
42
|
/**
|
43
|
-
*
|
43
|
+
* An inline wallet connection component that allows to:
|
44
44
|
*
|
45
|
-
*
|
45
|
+
* - Connect to 350+ external wallets
|
46
|
+
* - Connect with email, phone, passkey or socials
|
47
|
+
* - Convert any wallet to a ERC4337 smart wallet for gasless transactions
|
48
|
+
* - Sign in with ethereum (Auth)
|
49
|
+
*
|
50
|
+
* It renders the same UI as the [`ConnectButton`](https://portal.thirdweb.com/react/v5/ConnectButton) component's modal - but directly inline in the page instead of being in a modal.
|
51
|
+
*
|
52
|
+
* Once connected, the component does not render any UI. It only renders UI if wallet is not connected.
|
46
53
|
*
|
47
|
-
* It only renders UI if wallet is not connected
|
48
54
|
* @example
|
55
|
+
*
|
56
|
+
* ## Default setup
|
57
|
+
*
|
49
58
|
* ```tsx
|
59
|
+
* import { createThirdwebClient } from "thirdweb";
|
60
|
+
* import { ConnectEmbed } from "thirdweb/react";
|
61
|
+
*
|
62
|
+
* const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID" });
|
63
|
+
*
|
50
64
|
* <ConnectEmbed
|
51
65
|
* client={client}
|
52
66
|
* />
|
53
67
|
* ```
|
68
|
+
*
|
69
|
+
* [View all available config options](https://portal.thirdweb.com/references/typescript/v5/ConnectEmbedProps)
|
70
|
+
*
|
71
|
+
* ## Customization options
|
72
|
+
*
|
73
|
+
* ### Customizing wallet options
|
74
|
+
*
|
75
|
+
* ```tsx
|
76
|
+
* <ConnectEmbed
|
77
|
+
* client={client}
|
78
|
+
* wallets={[
|
79
|
+
* createWallet("io.metamask"),
|
80
|
+
* createWallet("com.coinbase.wallet"),
|
81
|
+
* createWallet("me.rainbow"),
|
82
|
+
* ]}
|
83
|
+
* />
|
84
|
+
* ```
|
85
|
+
*
|
86
|
+
* [View all available wallets](https://portal.thirdweb.com/typescript/v5/supported-wallets)
|
87
|
+
*
|
88
|
+
* ### Customizing the default chain to connect to
|
89
|
+
*
|
90
|
+
* ```tsx
|
91
|
+
* import { base } from "thirdweb/chains";
|
92
|
+
*
|
93
|
+
* <ConnectEmbed
|
94
|
+
* client={client}
|
95
|
+
* chain={base}
|
96
|
+
* />
|
97
|
+
* ```
|
98
|
+
*
|
99
|
+
* ### Enabling sign in with ethereum (Auth)
|
100
|
+
*
|
101
|
+
* ```tsx
|
102
|
+
* <ConnectEmbed
|
103
|
+
* client={client}
|
104
|
+
* auth={{
|
105
|
+
* isLoggedIn: async (address) => {
|
106
|
+
* console.log("checking if logged in!", { address });
|
107
|
+
* return await isLoggedIn();
|
108
|
+
* },
|
109
|
+
* doLogin: async (params) => {
|
110
|
+
* console.log("logging in!");
|
111
|
+
* await login(params);
|
112
|
+
* },
|
113
|
+
* getLoginPayload: async ({ address }) =>
|
114
|
+
* generatePayload({ address }),
|
115
|
+
* doLogout: async () => {
|
116
|
+
* console.log("logging out!");
|
117
|
+
* await logout();
|
118
|
+
* },
|
119
|
+
* }}
|
120
|
+
* />;
|
121
|
+
* ```
|
122
|
+
*
|
123
|
+
* ### Customizing the theme
|
124
|
+
*
|
125
|
+
* ```tsx
|
126
|
+
* <ConnectEmbed
|
127
|
+
* client={client}
|
128
|
+
* theme="light"
|
129
|
+
* />
|
130
|
+
* ```
|
131
|
+
*
|
132
|
+
* For more granular control, you can also pass a custom theme object:
|
133
|
+
*
|
134
|
+
* ```tsx
|
135
|
+
* <ConnectEmbed
|
136
|
+
* client={client}
|
137
|
+
* theme={lightTheme({
|
138
|
+
* colors: {
|
139
|
+
* modalBg: "red",
|
140
|
+
* },
|
141
|
+
* })}
|
142
|
+
* />
|
143
|
+
* ```
|
144
|
+
*
|
145
|
+
* [View all available themes properties](https://portal.thirdweb.com/references/typescript/v5/Theme)
|
146
|
+
*
|
147
|
+
* ### Changing the display language
|
148
|
+
*
|
149
|
+
* ```tsx
|
150
|
+
* <ConnectEmbed
|
151
|
+
* client={client}
|
152
|
+
* locale="ja_JP"
|
153
|
+
* />
|
154
|
+
* ```
|
155
|
+
*
|
156
|
+
* [View all available locales](https://portal.thirdweb.com/references/typescript/v5/LocaleId)
|
157
|
+
*
|
54
158
|
* @param props -
|
55
159
|
* The props for the `ConnectEmbed` component.
|
56
160
|
*
|
57
161
|
* Refer to the [`ConnectEmbedProps`](https://portal.thirdweb.com/references/typescript/v5/ConnectEmbedProps) type for more details
|
162
|
+
*
|
163
|
+
* @returns A JSX element that renders the <ConnectEmbed> component.
|
58
164
|
* @component
|
59
165
|
*/
|
60
166
|
export function ConnectEmbed(props: ConnectEmbedProps) {
|
@@ -234,7 +234,7 @@ export const ConnectWalletSocialOptions = (
|
|
234
234
|
props.select();
|
235
235
|
}
|
236
236
|
|
237
|
-
const showOnlyIcons = socialLogins.length >
|
237
|
+
const showOnlyIcons = socialLogins.length > 2;
|
238
238
|
|
239
239
|
return (
|
240
240
|
<Container
|
@@ -247,22 +247,33 @@ export const ConnectWalletSocialOptions = (
|
|
247
247
|
{/* Social Login */}
|
248
248
|
{hasSocialLogins && (
|
249
249
|
<Container
|
250
|
-
flex=
|
250
|
+
flex="row"
|
251
251
|
center="x"
|
252
|
-
gap="sm"
|
252
|
+
gap={socialLogins.length > 4 ? "xs" : "sm"}
|
253
253
|
style={{
|
254
254
|
justifyContent: "space-between",
|
255
|
+
display: "grid",
|
256
|
+
gridTemplateColumns: `repeat(${socialLogins.length}, 1fr)`,
|
255
257
|
}}
|
256
258
|
>
|
257
259
|
{socialLogins.map((loginMethod) => {
|
258
|
-
const imgIconSize =
|
260
|
+
const imgIconSize = (() => {
|
261
|
+
if (!showOnlyIcons) {
|
262
|
+
return iconSize.md;
|
263
|
+
} else {
|
264
|
+
if (socialLogins.length > 4) {
|
265
|
+
return iconSize.md;
|
266
|
+
}
|
267
|
+
return iconSize.lg;
|
268
|
+
}
|
269
|
+
})();
|
270
|
+
|
259
271
|
return (
|
260
272
|
<SocialButton
|
261
273
|
aria-label={`Login with ${loginMethod}`}
|
262
274
|
data-variant={showOnlyIcons ? "icon" : "full"}
|
263
275
|
key={loginMethod}
|
264
276
|
variant={"outline"}
|
265
|
-
fullWidth={!showOnlyIcons}
|
266
277
|
onClick={() => {
|
267
278
|
handleSocialLogin(loginMethod as SocialAuthOption);
|
268
279
|
}}
|
@@ -274,7 +285,7 @@ export const ConnectWalletSocialOptions = (
|
|
274
285
|
client={props.client}
|
275
286
|
/>
|
276
287
|
{!showOnlyIcons &&
|
277
|
-
loginMethodsLabel[loginMethod as SocialAuthOption]}
|
288
|
+
`${socialLogins.length === 1 ? "Continue with " : ""}${loginMethodsLabel[loginMethod as SocialAuthOption]}`}
|
278
289
|
</SocialButton>
|
279
290
|
);
|
280
291
|
})}
|
@@ -379,11 +390,12 @@ export const ConnectWalletSocialOptions = (
|
|
379
390
|
};
|
380
391
|
|
381
392
|
const SocialButton = /* @__PURE__ */ styled(Button)({
|
393
|
+
flexGrow: 1,
|
382
394
|
"&[data-variant='full']": {
|
383
395
|
display: "flex",
|
384
396
|
justifyContent: "flex-start",
|
385
397
|
padding: spacing.md,
|
386
|
-
gap: spacing.
|
398
|
+
gap: spacing.sm,
|
387
399
|
fontSize: fontSize.md,
|
388
400
|
fontWeight: 500,
|
389
401
|
transition: "background-color 0.2s ease",
|
@@ -393,6 +405,5 @@ const SocialButton = /* @__PURE__ */ styled(Button)({
|
|
393
405
|
},
|
394
406
|
"&[data-variant='icon']": {
|
395
407
|
padding: spacing.sm,
|
396
|
-
flexGrow: 1,
|
397
408
|
},
|
398
409
|
});
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.42.0
|
1
|
+
export const version = "5.42.0";
|
@@ -30,9 +30,31 @@ import { createWalletEmitter } from "./wallet-emitter.js";
|
|
30
30
|
|
31
31
|
/**
|
32
32
|
* Creates a wallet based on the provided ID and arguments.
|
33
|
+
*
|
34
|
+
* - Supports 350+ wallets
|
35
|
+
* - Handles both injected browser wallets and WalletConnect sessions
|
36
|
+
*
|
37
|
+
* [View all available wallets](https://portal.thirdweb.com/typescript/v5/supported-wallets)
|
38
|
+
*
|
33
39
|
* @param args - The arguments for creating the wallet.
|
40
|
+
* @param args.id - The ID of the wallet to create, this will be autocompleted by your IDE.
|
41
|
+
* [View all available wallets](https://portal.thirdweb.com/typescript/v5/supported-wallets)
|
42
|
+
* @param args.createOptions - The options for creating the wallet.
|
43
|
+
* The arguments are different for each wallet type.
|
44
|
+
* Refer to the [WalletCreationOptions](https://portal.thirdweb.com/references/typescript/v5/WalletCreationOptions) type for more details.
|
34
45
|
* @returns - The created wallet.
|
35
46
|
* @example
|
47
|
+
*
|
48
|
+
* ## Connecting the wallet
|
49
|
+
*
|
50
|
+
* Once created, you can connect the wallet to your app by calling the `connect` method.
|
51
|
+
*
|
52
|
+
* The `connect` method returns a promise that resolves to the connected account.
|
53
|
+
*
|
54
|
+
* Each wallet type can have different connect options. [View the different connect options](https://portal.thirdweb.com/references/typescript/v5/WalletConnectionOption)
|
55
|
+
*
|
56
|
+
* ## Connecting to an injected wallet
|
57
|
+
*
|
36
58
|
* ```ts
|
37
59
|
* import { createWallet } from "thirdweb/wallets";
|
38
60
|
*
|
@@ -42,6 +64,57 @@ import { createWalletEmitter } from "./wallet-emitter.js";
|
|
42
64
|
* client,
|
43
65
|
* });
|
44
66
|
* ```
|
67
|
+
*
|
68
|
+
* You can check if a wallet is installed by calling the [injectedProvider](https://portal.thirdweb.com/references/typescript/v5/injectedProvider) method.
|
69
|
+
*
|
70
|
+
* ## Connecting via WalletConnect modal
|
71
|
+
*
|
72
|
+
* ```ts
|
73
|
+
* import { createWallet } from "thirdweb/wallets";
|
74
|
+
*
|
75
|
+
* const metamaskWallet = createWallet("io.metamask");
|
76
|
+
*
|
77
|
+
* await metamask.connect({
|
78
|
+
* client,
|
79
|
+
* walletConnect: {
|
80
|
+
* projectId: "YOUR_PROJECT_ID",
|
81
|
+
* showQrModal: true,
|
82
|
+
* appMetadata: {
|
83
|
+
* name: "My App",
|
84
|
+
* url: "https://my-app.com",
|
85
|
+
* description: "my app description",
|
86
|
+
* logoUrl: "https://path/to/my-app/logo.svg",
|
87
|
+
* },
|
88
|
+
* },
|
89
|
+
* });
|
90
|
+
* ```
|
91
|
+
* [View ConnectWallet connection options](https://portal.thirdweb.com/references/typescript/v5/WCConnectOptions)
|
92
|
+
*
|
93
|
+
* ## Connecting with coinbase wallet
|
94
|
+
*
|
95
|
+
* ```ts
|
96
|
+
* import { createWallet } from "thirdweb/wallets";
|
97
|
+
*
|
98
|
+
* const cbWallet = createWallet("com.coinbase.wallet", {
|
99
|
+
* appMetadata: {
|
100
|
+
* name: "My App",
|
101
|
+
* url: "https://my-app.com",
|
102
|
+
* description: "my app description",
|
103
|
+
* logoUrl: "https://path/to/my-app/logo.svg",
|
104
|
+
* },
|
105
|
+
* walletConfig: {
|
106
|
+
* // options: 'all' | 'smartWalletOnly' | 'eoaOnly'
|
107
|
+
* options: 'all',
|
108
|
+
* },
|
109
|
+
* });
|
110
|
+
*
|
111
|
+
* const account = await cbWallet.connect({
|
112
|
+
* client,
|
113
|
+
* });
|
114
|
+
* ```
|
115
|
+
*
|
116
|
+
* [View Coinbase wallet creation options](https://portal.thirdweb.com/references/typescript/v5/CoinbaseWalletCreationOptions)
|
117
|
+
*
|
45
118
|
* @wallet
|
46
119
|
*/
|
47
120
|
export function createWallet<const ID extends WalletId>(
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { Prettify } from "../../utils/type-utils.js";
|
1
2
|
import type {
|
2
3
|
InAppWalletAutoConnectOptions,
|
3
4
|
InAppWalletConnectionOptions,
|
@@ -11,8 +12,11 @@ export type EcosystemWalletCreationOptions = {
|
|
11
12
|
};
|
12
13
|
};
|
13
14
|
|
14
|
-
export type EcosystemWalletConnectionOptions =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
export type EcosystemWalletConnectionOptions = Prettify<
|
16
|
+
InAppWalletConnectionOptions & {
|
17
|
+
ecosystem: Ecosystem;
|
18
|
+
}
|
19
|
+
>;
|
20
|
+
export type EcosystemWalletAutoConnectOptions = Prettify<
|
21
|
+
InAppWalletAutoConnectOptions & { ecosystem: Ecosystem }
|
22
|
+
>;
|
@@ -7,10 +7,29 @@ import type {
|
|
7
7
|
import { createEcosystemWallet } from "../core/wallet/ecosystem-core.js";
|
8
8
|
|
9
9
|
/**
|
10
|
-
* Creates an
|
10
|
+
* Creates an [Ecosystem Wallet](https://portal.thirdweb.com/connect/ecosystems/overview) based on various authentication methods.
|
11
|
+
*
|
12
|
+
* Available authentication methods:
|
13
|
+
* - Email
|
14
|
+
* - Phone
|
15
|
+
* - Passkey
|
16
|
+
* - Google
|
17
|
+
* - Apple
|
18
|
+
* - Facebook
|
19
|
+
* - Discord
|
20
|
+
* - Farcaster
|
21
|
+
*
|
22
|
+
* Can also be configured to use Account Abstraction to directly connect to a ERC4337 smart account based on those authentication methods.
|
23
|
+
*
|
24
|
+
* Refer to [inAppWallet](https://portal.thirdweb.com/references/typescript/v5/inAppWallet) for detailed usage examples.
|
25
|
+
*
|
11
26
|
* @param createOptions - configuration options
|
27
|
+
* Refer to [EcosystemWalletCreationOptions](https://portal.thirdweb.com/references/typescript/v5/EcosystemWalletCreationOptions) for more details.
|
12
28
|
* @returns The created ecosystem wallet.
|
13
29
|
* @example
|
30
|
+
*
|
31
|
+
* ### Connect to an ecosystem wallet
|
32
|
+
*
|
14
33
|
* ```ts
|
15
34
|
* import { ecosystemWallet } from "thirdweb/wallets";
|
16
35
|
*
|
@@ -23,14 +42,21 @@ import { createEcosystemWallet } from "../core/wallet/ecosystem-core.js";
|
|
23
42
|
* });
|
24
43
|
* ```
|
25
44
|
*
|
26
|
-
*
|
27
|
-
*
|
45
|
+
* [View all connection options](https://portal.thirdweb.com/references/typescript/v5/EcosystemWalletConnectionOptions)
|
46
|
+
*
|
47
|
+
* ### Connect to a restricted ecosystem wallet with your designated partner ID
|
48
|
+
*
|
49
|
+
* The parnter ID will be provided to you by the ecosystem with which you're integrating.
|
50
|
+
*
|
28
51
|
* ```ts
|
29
52
|
* import { ecosystemWallet } from "thirdweb/wallets";
|
30
53
|
* const wallet = ecosystemWallet("ecosystem.hooli", {
|
31
54
|
* partnerId: "..."
|
32
55
|
* });
|
33
56
|
* ```
|
57
|
+
*
|
58
|
+
* Refer to [inAppWallet](https://portal.thirdweb.com/references/typescript/v5/inAppWallet) for more usage examples.
|
59
|
+
*
|
34
60
|
* @wallet
|
35
61
|
*/
|
36
62
|
export function ecosystemWallet(
|
@@ -4,10 +4,27 @@ import type { CreateWalletArgs } from "../../wallet-types.js";
|
|
4
4
|
import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
5
5
|
|
6
6
|
/**
|
7
|
-
* Creates an
|
7
|
+
* Creates an app scoped wallet for users based on various authentication methods.
|
8
|
+
*
|
9
|
+
* Available authentication methods:
|
10
|
+
* - Email
|
11
|
+
* - Phone
|
12
|
+
* - Passkey
|
13
|
+
* - Google
|
14
|
+
* - Apple
|
15
|
+
* - Facebook
|
16
|
+
* - Discord
|
17
|
+
* - Farcaster
|
18
|
+
*
|
19
|
+
* Can also be configured to use Account Abstraction to directly connect to a ERC4337 smart account based on those authentication methods.
|
20
|
+
*
|
8
21
|
* @param createOptions - configuration options
|
22
|
+
* Refer to [InAppWalletCreationOptions](https://portal.thirdweb.com/references/typescript/v5/InAppWalletCreationOptions) to see the available options.
|
9
23
|
* @returns The created in-app wallet.
|
10
24
|
* @example
|
25
|
+
*
|
26
|
+
* ### Login with socials
|
27
|
+
*
|
11
28
|
* ```ts
|
12
29
|
* import { inAppWallet } from "thirdweb/wallets";
|
13
30
|
*
|
@@ -20,18 +37,90 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
20
37
|
* });
|
21
38
|
* ```
|
22
39
|
*
|
23
|
-
*
|
40
|
+
* [View all available social auth methods](https://portal.thirdweb.com/references/typescript/v5/InAppWalletSocialAuth)
|
41
|
+
*
|
42
|
+
* * ### Login with email
|
43
|
+
*
|
44
|
+
* ```ts
|
45
|
+
* import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
|
46
|
+
*
|
47
|
+
* const wallet = inAppWallet();
|
48
|
+
*
|
49
|
+
* // sends a verification code to the provided email
|
50
|
+
* await preAuthenticate({
|
51
|
+
* client,
|
52
|
+
* strategy: "email",
|
53
|
+
* email: "example@example.com",
|
54
|
+
* });
|
55
|
+
*
|
56
|
+
* // login with the verification code
|
57
|
+
* const account = await wallet.connect({
|
58
|
+
* client,
|
59
|
+
* chain,
|
60
|
+
* strategy: "email",
|
61
|
+
* verificationCode: "123456",
|
62
|
+
* });
|
63
|
+
* ```
|
64
|
+
*
|
65
|
+
* ### Login with phone number
|
66
|
+
* ```ts
|
67
|
+
* import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
|
68
|
+
*
|
69
|
+
* const wallet = inAppWallet();
|
70
|
+
*
|
71
|
+
* // sends a verification code to the provided phone number
|
72
|
+
* await preAuthenticate({
|
73
|
+
* client,
|
74
|
+
* strategy: "phone",
|
75
|
+
* phoneNumber: "+1234567890",
|
76
|
+
* });
|
77
|
+
*
|
78
|
+
* // login with the verification code
|
79
|
+
* const account = await wallet.connect({
|
80
|
+
* client,
|
81
|
+
* chain,
|
82
|
+
* strategy: "phone",
|
83
|
+
* verificationCode: "123456",
|
84
|
+
* });
|
85
|
+
*
|
86
|
+
* ### Login with passkey
|
87
|
+
*
|
88
|
+
* ```ts
|
89
|
+
* import { inAppWallet, hasStoredPasskey } from "thirdweb/wallets/in-app";
|
90
|
+
*
|
91
|
+
* const wallet = inAppWallet();
|
92
|
+
*
|
93
|
+
* const wallet = inAppWallet();
|
94
|
+
* const hasPasskey = await hasStoredPasskey(client);
|
95
|
+
* await wallet.connect({
|
96
|
+
* client,
|
97
|
+
* strategy: "passkey",
|
98
|
+
* type: hasPasskey ? "sign-in" : "sign-up",
|
99
|
+
* });
|
100
|
+
* ```
|
101
|
+
*
|
102
|
+
* ### Enable smart accounts and sponsor gas for your users:
|
103
|
+
*
|
24
104
|
* ```ts
|
25
105
|
* import { inAppWallet } from "thirdweb/wallets";
|
106
|
+
* import { sepolia } from "thirdweb/chains";
|
107
|
+
*
|
26
108
|
* const wallet = inAppWallet({
|
27
109
|
* smartAccount: {
|
28
110
|
* chain: sepolia,
|
29
111
|
* sponsorGas: true,
|
30
112
|
* },
|
31
113
|
* });
|
114
|
+
*
|
115
|
+
* // account will be a smart account with sponsored gas enabled
|
116
|
+
* const account = await wallet.connect({
|
117
|
+
* client,
|
118
|
+
* chain,
|
119
|
+
* strategy: "google",
|
120
|
+
* });
|
32
121
|
* ```
|
33
122
|
*
|
34
|
-
* Specify a logo for your login page
|
123
|
+
* ### Specify a logo for your login page (Connect UI)
|
35
124
|
* ```ts
|
36
125
|
* import { inAppWallet } from "thirdweb/wallets";
|
37
126
|
* const wallet = inAppWallet({
|
@@ -46,7 +135,8 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
46
135
|
* });
|
47
136
|
* ```
|
48
137
|
*
|
49
|
-
* Hide the ability to export the private key within the Connect Modal
|
138
|
+
* ### Hide the ability to export the private key within the Connect Modal UI
|
139
|
+
*
|
50
140
|
* ```ts
|
51
141
|
* import { inAppWallet } from "thirdweb/wallets";
|
52
142
|
* const wallet = inAppWallet({
|
@@ -54,7 +144,10 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
54
144
|
* });
|
55
145
|
* ```
|
56
146
|
*
|
57
|
-
* Open the Oauth window in the same tab
|
147
|
+
* ### Open the Oauth window in the same tab
|
148
|
+
*
|
149
|
+
* By default, the Oauth window will open in a popup window. You can change this behavior by setting the `auth.mode` option to `"redirect"`.
|
150
|
+
*
|
58
151
|
* ```ts
|
59
152
|
* import { inAppWallet } from "thirdweb/wallets";
|
60
153
|
* const wallet = inAppWallet({
|
@@ -63,6 +156,8 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
63
156
|
* }
|
64
157
|
* });
|
65
158
|
* ```
|
159
|
+
*
|
160
|
+
* @returns The created in-app wallet.
|
66
161
|
* @wallet
|
67
162
|
*/
|
68
163
|
export function inAppWallet(
|
@@ -11,23 +11,89 @@ import type {
|
|
11
11
|
import { DEFAULT_ACCOUNT_FACTORY } from "./lib/constants.js";
|
12
12
|
|
13
13
|
/**
|
14
|
-
* Creates a smart wallet.
|
14
|
+
* Creates a ERC4337 smart wallet based on a admin account.
|
15
|
+
*
|
16
|
+
* Smart wallets are smart contract wallets that enable multiple benefits for users:
|
17
|
+
*
|
18
|
+
* - Sponsor gas fees for transactions
|
19
|
+
* - Multiple owners
|
20
|
+
* - Session keys
|
21
|
+
* - Batch transactions
|
22
|
+
* - Predictable addresses
|
23
|
+
* - Programmable features
|
24
|
+
*
|
25
|
+
* [Learn more about account abstraction](https://portal.thirdweb.com/connect/account-abstraction/how-it-works)
|
26
|
+
*
|
15
27
|
* @param createOptions - The options for creating the wallet.
|
28
|
+
* Refer to [SmartWalletCreationOptions](https://portal.thirdweb.com/references/typescript/v5/SmartWalletCreationOptions) for more details.
|
16
29
|
* @returns The created smart wallet.
|
17
30
|
* @example
|
31
|
+
*
|
32
|
+
* ## Connect to a smart wallet
|
33
|
+
*
|
34
|
+
* To connect to a smart wallet, you need to provide an admin account as the `personalAccount` option.
|
35
|
+
*
|
36
|
+
* Any wallet can be used as an admin account, including an in-app wallets.
|
37
|
+
*
|
38
|
+
* The `sponsorGas` option is used to enable sponsored gas for transactions automatically.
|
39
|
+
*
|
18
40
|
* ```ts
|
19
|
-
* import {
|
41
|
+
* import { smartWalletm inAppWallet } from "thirdweb/wallets";
|
42
|
+
* import { sepolia } from "thirdweb/chains";
|
43
|
+
* import { sendTransaction } from "thirdweb";
|
20
44
|
*
|
21
45
|
* const wallet = smartWallet({
|
22
46
|
* chain: sepolia,
|
23
|
-
*
|
47
|
+
* sponsorGas: true, // enable sponsored transactions
|
24
48
|
* });
|
25
49
|
*
|
26
|
-
*
|
50
|
+
* // any wallet can be used as an admin account
|
51
|
+
* // in this example we use an in-app wallet
|
52
|
+
* const adminWallet = inAppWallet();
|
53
|
+
* const personalAccount = await adminWallet.connect({
|
27
54
|
* client,
|
28
|
-
*
|
55
|
+
* chain: sepolia,
|
56
|
+
* strategy: "google",
|
57
|
+
* });
|
58
|
+
*
|
59
|
+
* const smartAccount = await wallet.connect({
|
60
|
+
* client,
|
61
|
+
* personalAccount, // pass the admin account
|
62
|
+
* });
|
63
|
+
*
|
64
|
+
* // sending sponsored transactions with the smartAccount
|
65
|
+
* await sendTransaction({
|
66
|
+
* account: smartAccount,
|
67
|
+
* transaction,
|
29
68
|
* });
|
30
69
|
* ```
|
70
|
+
*
|
71
|
+
* ## Configuring the smart wallet
|
72
|
+
*
|
73
|
+
* You can pass options to the `smartWallet` function to configure the smart wallet.
|
74
|
+
*
|
75
|
+
* ```ts
|
76
|
+
* import { smartWallet } from "thirdweb/wallets";
|
77
|
+
* import { sepolia } from "thirdweb/chains";
|
78
|
+
*
|
79
|
+
* const wallet = smartWallet({
|
80
|
+
* chain: sepolia,
|
81
|
+
* sponsorGas: true, // enable sponsored transactions
|
82
|
+
* factoryAddress: "0x...", // custom factory address
|
83
|
+
* overrides: {
|
84
|
+
* accountAddress: "0x...", // override account address
|
85
|
+
* accountSalt: "0x...", // override account salt
|
86
|
+
* entrypointAddress: "0x...", // override entrypoint address
|
87
|
+
* erc20Paymaster: { ... }, // enable erc20 paymaster
|
88
|
+
* bundlerUrl: "https://...", // override bundler url
|
89
|
+
* paymaster: (userOp) => { ... }, // override paymaster
|
90
|
+
* ...
|
91
|
+
* }
|
92
|
+
* });
|
93
|
+
* ```
|
94
|
+
*
|
95
|
+
* Refer to [SmartWalletOptions](https://portal.thirdweb.com/references/typescript/v5/SmartWalletOptions) for more details.
|
96
|
+
*
|
31
97
|
* @wallet
|
32
98
|
*/
|
33
99
|
export function smartWallet(
|