Skip to content

[SDK] Feature: Add wagmi adapter for in-app wallet #5644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/strong-panthers-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
"@thirdweb-dev/wagmi-adapter": minor
---

Wagmi connector for in-app wallets

You can now connect to an in-app wallet in your wagmi applications.

Install the wagmi adapter:

```bash
npm install @thirdweb-dev/wagmi-adapter
```

Create a wagmi config with the in-app wallet connector:

```ts
import { http, createConfig } from "wagmi";
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
import { createThirdwebClient, defineChain as thirdwebChain } from "thirdweb";

const client = createThirdwebClient({
clientId: "...",
});

export const config = createConfig({
chains: [sepolia],
connectors: [
inAppWalletConnector({
client,
// optional: turn on smart accounts
smartAccounts: {
sponsorGas: true,
chain: thirdwebChain(sepolia),
},
}),
],
transports: {
[sepolia.id]: http(),
},
});
```

Then in your app, you can use the connector to connect with any supported strategy:

```ts
const { connect, connectors } = useConnect();

const onClick = () => {
const inAppWallet = connectors.find((x) => x.id === "in-app-wallet");
connect({
connector: inAppWallet,
strategy: "google",
});
};
```
6 changes: 6 additions & 0 deletions packages/thirdweb/src/exports/wallets.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ export type {
* @deprecated use InAppWalletSocialAuth instead
*/
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
InAppWalletCreationOptions,
} from "../wallets/in-app/core/wallet/types.js";

export type {
MultiStepAuthArgsType,
SingleStepAuthArgsType,
} from "../wallets/in-app/core/authentication/types.js";

export {
preAuthenticate,
authenticate,
Expand Down
6 changes: 6 additions & 0 deletions packages/thirdweb/src/exports/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ export type {
* @deprecated use InAppWalletSocialAuth instead
*/
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
InAppWalletCreationOptions,
} from "../wallets/in-app/core/wallet/types.js";

export type {
MultiStepAuthArgsType,
SingleStepAuthArgsType,
} from "../wallets/in-app/core/authentication/types.js";

export {
preAuthenticate,
authenticate,
Expand Down
6 changes: 6 additions & 0 deletions packages/thirdweb/src/exports/wallets/in-app.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export type {
InAppWalletAuth,
InAppWalletSocialAuth,
InAppWalletConnectionOptions,
InAppWalletAutoConnectOptions,
} from "../../wallets/in-app/core/wallet/types.js";

export type {
MultiStepAuthArgsType,
SingleStepAuthArgsType,
} from "../../wallets/in-app/core/authentication/types.js";

export { hasStoredPasskey } from "../../wallets/in-app/native/auth/passkeys.js";
6 changes: 6 additions & 0 deletions packages/thirdweb/src/exports/wallets/in-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ export type {
InAppWalletAuth,
InAppWalletSocialAuth,
InAppWalletConnectionOptions,
InAppWalletAutoConnectOptions,
} from "../../wallets/in-app/core/wallet/types.js";

export type {
MultiStepAuthArgsType,
SingleStepAuthArgsType,
} from "../../wallets/in-app/core/authentication/types.js";

export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";

export {
Expand Down
15 changes: 7 additions & 8 deletions packages/thirdweb/src/wallets/in-app/core/wallet/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Chain } from "../../../../chains/types.js";
import type { ThirdwebClient } from "../../../../client/client.js";
import type { SupportedSmsCountry } from "../../../../react/web/wallets/in-app/supported-sms-countries.js";
import type { Prettify } from "../../../../utils/type-utils.js";
import type { SmartWalletOptions } from "../../../smart/types.js";
import type {
AuthOption,
Expand All @@ -20,14 +21,12 @@ export type Ecosystem = {
partnerId?: string;
};

export type InAppWalletConnectionOptions = (
| MultiStepAuthArgsType
| SingleStepAuthArgsType
) & {
client: ThirdwebClient;
chain?: Chain;
redirect?: boolean;
};
export type InAppWalletConnectionOptions = Prettify<
(MultiStepAuthArgsType | SingleStepAuthArgsType) & {
client: ThirdwebClient;
chain?: Chain;
}
>;

export type InAppWalletAutoConnectOptions = {
client: ThirdwebClient;
Expand Down
Loading
Loading