Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/tangy-bugs-feel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Show injected wallet icon when available
11 changes: 10 additions & 1 deletion packages/thirdweb/src/react/core/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,19 @@
export function useWalletImage(id: WalletId | undefined) {
return useQuery({
queryKey: ["wallet-image", id],
queryFn: () => {
queryFn: async () => {
if (!id) {
throw new Error("Wallet id is required");
}
const { getInstalledWalletProviders } = await import(
Copy link
Member

Choose a reason for hiding this comment

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

same question RE async import

Copy link
Member Author

Choose a reason for hiding this comment

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

same answer

"../../../wallets/injected/mipdStore.js"
);
const mipdImage = getInstalledWalletProviders().find(
(x) => x.info.rdns === id,
)?.info.icon;
if (mipdImage) {
return mipdImage;
}

Check warning on line 209 in packages/thirdweb/src/react/core/utils/wallet.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/utils/wallet.ts#L208-L209

Added lines #L208 - L209 were not covered by tests
return getWalletInfo(id, true);
},
retry: false,
Expand Down
13 changes: 10 additions & 3 deletions packages/thirdweb/src/react/core/utils/walletIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,15 @@
/**
* @internal Exported for tests only
*/
export async function fetchWalletImage(props: {
id: WalletId;
}) {
export async function fetchWalletImage(props: { id: WalletId }) {
const { getInstalledWalletProviders } = await import(
Copy link
Member

Choose a reason for hiding this comment

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

why the async import here? this will ALWAYS be hit when the function is called (not in an optional branch) so it would be more efficient to have it as part of the main bundle regardless

Copy link
Member Author

Choose a reason for hiding this comment

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

because this is core, which is imported by react native and i rather not trigger this import unless i import that function if im just grabbing an icon const

"../../../wallets/injected/mipdStore.js"
);
const mipdImage = getInstalledWalletProviders().find(
(x) => x.info.rdns === props.id,
)?.info.icon;
if (mipdImage) {
return mipdImage;
}

Check warning on line 141 in packages/thirdweb/src/react/core/utils/walletIcon.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/utils/walletIcon.ts#L140-L141

Added lines #L140 - L141 were not covered by tests
return getWalletInfo(props.id, true);
}
Loading