Skip to content

Commit 8d2e2ad

Browse files
[SDK] Feature: Add wagmi adapter for in-app wallet (#5644)
1 parent c91ca93 commit 8d2e2ad

File tree

15 files changed

+617
-164
lines changed

15 files changed

+617
-164
lines changed

.changeset/strong-panthers-notice.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
"@thirdweb-dev/wagmi-adapter": minor
3+
---
4+
5+
Wagmi connector for in-app wallets
6+
7+
You can now connect to an in-app wallet in your wagmi applications.
8+
9+
Install the wagmi adapter:
10+
11+
```bash
12+
npm install @thirdweb-dev/wagmi-adapter
13+
```
14+
15+
Create a wagmi config with the in-app wallet connector:
16+
17+
```ts
18+
import { http, createConfig } from "wagmi";
19+
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
20+
import { createThirdwebClient, defineChain as thirdwebChain } from "thirdweb";
21+
22+
const client = createThirdwebClient({
23+
clientId: "...",
24+
});
25+
26+
export const config = createConfig({
27+
chains: [sepolia],
28+
connectors: [
29+
inAppWalletConnector({
30+
client,
31+
// optional: turn on smart accounts
32+
smartAccounts: {
33+
sponsorGas: true,
34+
chain: thirdwebChain(sepolia),
35+
},
36+
}),
37+
],
38+
transports: {
39+
[sepolia.id]: http(),
40+
},
41+
});
42+
```
43+
44+
Then in your app, you can use the connector to connect with any supported strategy:
45+
46+
```ts
47+
const { connect, connectors } = useConnect();
48+
49+
const onClick = () => {
50+
const inAppWallet = connectors.find((x) => x.id === "in-app-wallet");
51+
connect({
52+
connector: inAppWallet,
53+
strategy: "google",
54+
});
55+
};
56+
```

packages/thirdweb/src/exports/wallets.native.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ export type {
8989
* @deprecated use InAppWalletSocialAuth instead
9090
*/
9191
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
92+
InAppWalletCreationOptions,
9293
} from "../wallets/in-app/core/wallet/types.js";
9394

95+
export type {
96+
MultiStepAuthArgsType,
97+
SingleStepAuthArgsType,
98+
} from "../wallets/in-app/core/authentication/types.js";
99+
94100
export {
95101
preAuthenticate,
96102
authenticate,

packages/thirdweb/src/exports/wallets.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ export type {
9696
* @deprecated use InAppWalletSocialAuth instead
9797
*/
9898
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
99+
InAppWalletCreationOptions,
99100
} from "../wallets/in-app/core/wallet/types.js";
100101

102+
export type {
103+
MultiStepAuthArgsType,
104+
SingleStepAuthArgsType,
105+
} from "../wallets/in-app/core/authentication/types.js";
106+
101107
export {
102108
preAuthenticate,
103109
authenticate,

packages/thirdweb/src/exports/wallets/in-app.native.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export type {
1818
InAppWalletAuth,
1919
InAppWalletSocialAuth,
2020
InAppWalletConnectionOptions,
21+
InAppWalletAutoConnectOptions,
2122
} from "../../wallets/in-app/core/wallet/types.js";
2223

24+
export type {
25+
MultiStepAuthArgsType,
26+
SingleStepAuthArgsType,
27+
} from "../../wallets/in-app/core/authentication/types.js";
28+
2329
export { hasStoredPasskey } from "../../wallets/in-app/native/auth/passkeys.js";

packages/thirdweb/src/exports/wallets/in-app.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ export type {
1818
InAppWalletAuth,
1919
InAppWalletSocialAuth,
2020
InAppWalletConnectionOptions,
21+
InAppWalletAutoConnectOptions,
2122
} from "../../wallets/in-app/core/wallet/types.js";
2223

24+
export type {
25+
MultiStepAuthArgsType,
26+
SingleStepAuthArgsType,
27+
} from "../../wallets/in-app/core/authentication/types.js";
28+
2329
export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";
2430

2531
export {

packages/thirdweb/src/wallets/in-app/core/wallet/types.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Chain } from "../../../../chains/types.js";
22
import type { ThirdwebClient } from "../../../../client/client.js";
33
import type { SupportedSmsCountry } from "../../../../react/web/wallets/in-app/supported-sms-countries.js";
4+
import type { Prettify } from "../../../../utils/type-utils.js";
45
import type { SmartWalletOptions } from "../../../smart/types.js";
56
import type {
67
AuthOption,
@@ -20,14 +21,12 @@ export type Ecosystem = {
2021
partnerId?: string;
2122
};
2223

23-
export type InAppWalletConnectionOptions = (
24-
| MultiStepAuthArgsType
25-
| SingleStepAuthArgsType
26-
) & {
27-
client: ThirdwebClient;
28-
chain?: Chain;
29-
redirect?: boolean;
30-
};
24+
export type InAppWalletConnectionOptions = Prettify<
25+
(MultiStepAuthArgsType | SingleStepAuthArgsType) & {
26+
client: ThirdwebClient;
27+
chain?: Chain;
28+
}
29+
>;
3130

3231
export type InAppWalletAutoConnectOptions = {
3332
client: ThirdwebClient;

0 commit comments

Comments
 (0)