-
Notifications
You must be signed in to change notification settings - Fork 627
[SDK] Allow passing activeWallet to SwapWidget #8504
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
graphite-app
merged 1 commit into
main
from
_SDK_Allow_passing_activeWallet_to_SwapWidget
Dec 5, 2025
+256
−10
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "thirdweb": patch | ||
| --- | ||
|
|
||
| Allow passing an activeWallet to SwapWidget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/hooks.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,27 @@ | ||
| import { useMemo } from "react"; | ||
| import type { Wallet } from "../../../../../wallets/interfaces/wallet.js"; | ||
| import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js"; | ||
| import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js"; | ||
| import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js"; | ||
| import type { ActiveWalletInfo } from "./types.js"; | ||
|
|
||
| export function useActiveWalletInfo(): ActiveWalletInfo | undefined { | ||
| export function useActiveWalletInfo( | ||
| activeWalletOverride?: Wallet, | ||
| ): ActiveWalletInfo | undefined { | ||
| const activeAccount = useActiveAccount(); | ||
| const activeWallet = useActiveWallet(); | ||
| const activeChain = useActiveWalletChain(); | ||
|
|
||
| return useMemo(() => { | ||
| return activeAccount && activeWallet && activeChain | ||
| const wallet = activeWalletOverride || activeWallet; | ||
| const chain = activeWalletOverride?.getChain() || activeChain; | ||
| const account = activeWalletOverride?.getAccount() || activeAccount; | ||
| return wallet && chain && account | ||
| ? { | ||
| activeChain, | ||
| activeWallet, | ||
| activeAccount, | ||
| activeChain: chain, | ||
| activeWallet: wallet, | ||
| activeAccount: account, | ||
| } | ||
| : undefined; | ||
| }, [activeAccount, activeWallet, activeChain]); | ||
| }, [activeAccount, activeWallet, activeChain, activeWalletOverride]); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
THIRDWEB_ENGINE_CLOUD_URLconstant uses a full URL format withhttps://protocol, but this causes a crash when the environment variable is set to just a hostname (which is the pattern used for all other domain constants).View Details
📝 Patch Details
Analysis
Inconsistent URL format in THIRDWEB_ENGINE_CLOUD_URL causes crash with environment variable override
What fails:
THIRDWEB_ENGINE_CLOUD_URLuses a full URL format with protocol ("https://engine.thirdweb-dev.com"), but the code that uses it inthirdweb.server.tsline 42 callsnew URL(THIRDWEB_ENGINE_CLOUD_URL).hostnameto extract the hostname. This causes aTypeError: Invalid URLwhen the environment variableNEXT_PUBLIC_ENGINE_CLOUD_URLis set to a hostname-only value (following the pattern of all other domain constants likeTHIRDWEB_PAY_DOMAIN,THIRDWEB_BUNDLER_DOMAIN, etc.).How to reproduce:
NEXT_PUBLIC_ENGINE_CLOUD_URL=engine.thirdweb-dev.com(hostname only, like other domain env vars)getConfiguredThirdwebClient()function inthirdweb.server.tscallssetThirdwebDomains()which executesnew URL(THIRDWEB_ENGINE_CLOUD_URL).hostnameTypeError: Invalid URLResult: Application crashes with invalid URL error in non-production environments when the environment variable is set to a hostname-only value.
Expected: The constant should follow the same pattern as all other domain constants in the thirdweb SDK - storing just the hostname without protocol. The
setThirdwebDomains()function expects domain names without protocols and automatically adds the correct protocol (https://for normal domains,http://for localhost).Changes made:
THIRDWEB_ENGINE_CLOUD_URLconstant from"https://engine.thirdweb-dev.com"to"engine.thirdweb-dev.com"inapps/dashboard/src/@/constants/urls.tsapps/dashboard/src/@/constants/thirdweb.server.tsline 42 fromnew URL(THIRDWEB_ENGINE_CLOUD_URL).hostnametoTHIRDWEB_ENGINE_CLOUD_URLto pass the hostname directly, consistent with all other domain parameters