Skip to content

[SDK] Fix: Add custom title & icon to wagmi connectors #6858

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 3 commits into from
Apr 26, 2025

Conversation

mmahdigh
Copy link
Contributor

@mmahdigh mmahdigh commented Apr 25, 2025

Hi!

I've been trying to use thirdweb's wagmi-adaptor with ConnectKit, but I'm having trouble setting an icon or title for my connectors. So they end up looking like this:

Screenshot 2025-04-25 at 6 43 28 PM

This is my code:

"use client";
import { createConfig, WagmiProvider, type Transport } from "wagmi";
import { mainnet } from "wagmi/chains";
import { ConnectKitProvider, getDefaultConfig, SIWEProvider } from "connectkit";
import {
  createThirdwebClient,
  defineChain as thirdwebDefineChain,
} from "thirdweb";
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
import { getTransportForChain } from "@/lib/utils";

const thirdwebClientId =
  process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID

// Create Thirdweb Client
const client = createThirdwebClient({
  clientId: thirdwebClientId,
});

// Define the custom icon source
const unicornIconSrc =
  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAA...";

const unicornConnector = inAppWalletConnector({
  client,
  smartAccount: {
    sponsorGas: true,
    chain: thirdwebDefineChain(mainnet.id),
    factoryAddress: unicornFactoryAddress,
  },
  metadata: {
    image: {
      src: unicornIconSrc,
      alt: "Unicorn.eth",
      height: 100,
      width: 100,
    },
  },
});

const metadata = {
  name: "Agora Next",
  description: "The on-chain governance company",
  url: process.env.NEXT_PUBLIC_AGORA_BASE_URL!,
  icons: ["https://avatars.githubusercontent.com/u/37784886"],
};
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!;
const { contracts, ui } = Tenant.current();
const shouldHideAgoraBranding = ui.hideAgoraBranding;

const baseConfig = getDefaultConfig({
  walletConnectProjectId: projectId,
  chains: [contracts.token.chain, mainnet],
  transports: {
    [mainnet.id]: getTransportForChain(mainnet.id)!,
    [contracts.token.chain.id]: getTransportForChain(contracts.token.chain.id)!,
  },
  appName: metadata.name,
  appDescription: metadata.description,
  appUrl: metadata.url,
});
export const config = createConfig({
  ...baseConfig,
  connectors: [unicornConnector, ...(baseConfig.connectors ?? [])],
});

The problem is, ConnectKit looks for the icon and name properties in a connector, but these properties are not set in the inAppWalletConnector function, so as a result, there's no icon to show, and the wallet's name is always "In-App wallet".


PR-Codex overview

This PR focuses on enhancing the inAppWallet metadata by adding customizable name and icon properties. This allows for better personalization of in-app wallets within the connect modal.

Detailed summary

  • Added name and icon properties to inAppWallet metadata in types.ts.
  • Updated InAppWalletSelectionUI.tsx to use wallet object instead of walletId.
  • Refactored connector.ts to retrieve name and icon from metadata.
  • Modified WalletEntryButton.tsx to use wallet object and display custom metadata.
  • Adjusted AllWalletsUI.tsx to create wallet from walletInfo.id.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@mmahdigh mmahdigh requested review from a team as code owners April 25, 2025 15:14
Copy link

changeset-bot bot commented Apr 25, 2025

🦋 Changeset detected

Latest commit: 9a0199f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@thirdweb-dev/wagmi-adapter Patch
thirdweb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 25, 2025

@mmahdigh is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

graphite-app bot commented Apr 25, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Apr 25, 2025
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 4.34783% with 22 lines in your changes missing coverage. Please review.

Project coverage is 35.51%. Comparing base (68aa693) to head (9a0199f).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...c/react/web/ui/ConnectWallet/WalletEntryButton.tsx 5.00% 19 Missing ⚠️
.../react/web/ui/ConnectWallet/Modal/AllWalletsUI.tsx 0.00% 2 Missing ⚠️
.../src/react/web/ui/ConnectWallet/WalletSelector.tsx 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (4.34%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (68aa693) and HEAD (9a0199f). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (68aa693) HEAD (9a0199f)
packages 2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6858       +/-   ##
===========================================
- Coverage   55.31%   35.51%   -19.80%     
===========================================
  Files         896      893        -3     
  Lines       57023    56907      -116     
  Branches     3971     2222     -1749     
===========================================
- Hits        31541    20213    -11328     
- Misses      25385    36623    +11238     
+ Partials       97       71       -26     
Flag Coverage Δ
packages 35.51% <4.34%> (-19.80%) ⬇️
Files with missing lines Coverage Δ
.../src/react/web/ui/ConnectWallet/WalletSelector.tsx 9.87% <0.00%> (ø)
.../react/web/ui/ConnectWallet/Modal/AllWalletsUI.tsx 14.93% <0.00%> (ø)
...c/react/web/ui/ConnectWallet/WalletEntryButton.tsx 14.28% <5.00%> (-1.90%) ⬇️

... and 282 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -69,6 +69,7 @@ export type InAppWalletCreationOptions =
* Metadata to display in the Connect Modal
*/
metadata?: {
name?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

This is actually useful for our own connect modal too.

Could replace the "social login" default name that we show in the wide modal.

As for the icon, can you actually add a separate prop for it instead of overloading image?

So name / icon / image.

That way we can also use it in the connect modal to let you replace the icon separately to the image that shows above the sign in options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it for you :) merging shortly

@@ -69,6 +69,7 @@ export type InAppWalletCreationOptions =
* Metadata to display in the Connect Modal
*/
metadata?: {
name?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it for you :) merging shortly

@joaquim-verges joaquim-verges merged commit adcbec6 into thirdweb-dev:main Apr 26, 2025
16 of 22 checks passed
@joaquim-verges joaquim-verges mentioned this pull request Apr 24, 2025
@mmahdigh
Copy link
Contributor Author

Thank you very much buddy! Lightning-fast reviews and merges 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants