-
Notifications
You must be signed in to change notification settings - Fork 90
feat: Stellar wallet connection #245
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
Open
emarc99
wants to merge
17
commits into
starkyorg:main
Choose a base branch
from
emarc99:feat-stellar-wallet-connect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d40cd9e
feat: add Stellar Mainnet and Testnet network configurations
emarc99 256bb73
feat: implement dynamic blockchain network detection and routing
emarc99 124570d
feat: implement Stellar wallet connection with Freighter integration
emarc99 6c4e6a6
feat: implement cryptographic signature verification for Stellar
emarc99 a96e478
feat: add Stellar blockchain verification API and UI
emarc99 b6c33c6
fix: update network configs and Discord select menu validation
emarc99 f8ea8cf
feat: add unified wallet connection and Stellar environment setup
emarc99 253f6ce
feat: add Stellar network configurations and fix type definitions
emarc99 51c2ed3
Merge branch 'main' of origin into feat-stellar-wallet-connect
emarc99 e213251
chore: delete irrelevant hook
emarc99 9013008
fix: mainnet signature verification
emarc99 ed78daa
fix: restored Stellar UI Features
emarc99 97c6a26
chore: remove unnecessary env variables & comments
emarc99 0d1167a
chore: remove stellar checks in ethereum context
emarc99 3e6ef42
chore: route to stellar verification page when conneted to stellar
emarc99 a97f598
chore: resolve conflicts
emarc99 3c8b770
chore: minor changes
emarc99 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { useRouter } from "next/router"; | ||
| import { useEffect, useState } from "react"; | ||
| import { NetworkName } from "../../types/networks"; | ||
| import { | ||
| getChainType, | ||
| getVerifyPageForNetwork, | ||
| } from "../../utils/networkDetection"; | ||
|
|
||
| type Props = { | ||
| network: NetworkName; | ||
| discordServerId: string; | ||
| discordMemberId: string; | ||
| customLink: string; | ||
| }; | ||
|
|
||
| const DynamicVerificationRouter = ({ | ||
| network, | ||
| discordServerId, | ||
| discordMemberId, | ||
| customLink, | ||
| }: Props) => { | ||
| const router = useRouter(); | ||
| const [isRouting, setIsRouting] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const routeToCorrectPage = async () => { | ||
| try { | ||
| setIsRouting(true); | ||
| const chainType = getChainType(network); | ||
|
|
||
| if (!chainType) { | ||
| console.error(`Unknown chain type for network: ${network}`); | ||
| return; | ||
| } | ||
|
|
||
| const correctVerifyPage = getVerifyPageForNetwork(network); | ||
| const currentPath = router.asPath; | ||
| const targetPath = `/${correctVerifyPage}/${discordServerId}/${discordMemberId}/${customLink}`; | ||
|
|
||
| // Only route if we're not already on the correct page | ||
| if (!currentPath.includes(`/${correctVerifyPage}/`)) { | ||
| console.log( | ||
| `Routing from current page to ${targetPath} for ${chainType} network` | ||
| ); | ||
| await router.replace(targetPath); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error during dynamic routing:", error); | ||
| } finally { | ||
| setIsRouting(false); | ||
| } | ||
| }; | ||
|
|
||
| if (network && discordServerId && discordMemberId && customLink) { | ||
| routeToCorrectPage(); | ||
| } | ||
| }, [network, discordServerId, discordMemberId, customLink, router]); | ||
|
|
||
| if (isRouting) { | ||
| return ( | ||
| <div style={{ textAlign: "center", padding: "2rem" }}> | ||
| <p> | ||
| Detecting network type and routing to the appropriate wallet | ||
| connection... | ||
| </p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| }; | ||
|
|
||
| export default DynamicVerificationRouter; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { useCallback, useState } from "react"; | ||
| import axios from "axios"; | ||
| import WatchTowerLogger from "../watchTower"; | ||
|
|
||
| const useStellarSignatureVerification = ( | ||
| network: string, | ||
| discordServerId: string, | ||
| discordMemberId: string, | ||
| customLink: string | ||
| ) => { | ||
| const [verifyingSignature, setVerifyingSignature] = useState<boolean>(false); | ||
| const [verifiedSignature, setVerifiedSignature] = useState<boolean>(false); | ||
| const [unverifiedSignature, setUnverifiedSignature] = useState<string>(""); | ||
|
|
||
| const verifySignature = useCallback( | ||
| async (signature: string, account: string, message: string) => { | ||
| if (!account) return; | ||
| setUnverifiedSignature(""); | ||
| setVerifyingSignature(true); | ||
| try { | ||
| await axios.post("/api/verify-stellar", { | ||
| account, | ||
| signature, | ||
| discordServerId, | ||
| discordMemberId, | ||
| customLink, | ||
| network, | ||
| message, | ||
| }); | ||
| setVerifiedSignature(true); | ||
| setVerifyingSignature(false); | ||
| } catch (e: any) { | ||
| WatchTowerLogger.error( | ||
| "Stellar signature verification failed with data", | ||
| e.response?.data | ||
| ); | ||
| setVerifyingSignature(false); | ||
| setUnverifiedSignature( | ||
| `${e.response?.data?.message || "Verification failed"}.${ | ||
| e.response?.data?.error || "" | ||
| }` || "Stellar signature verification failed" | ||
| ); | ||
| } | ||
| setVerifyingSignature(false); | ||
| }, | ||
| [network, discordServerId, discordMemberId, customLink] | ||
| ); | ||
|
|
||
| return { | ||
| verifyingSignature, | ||
| verifiedSignature, | ||
| unverifiedSignature, | ||
| verifySignature, | ||
| }; | ||
| }; | ||
|
|
||
| export default useStellarSignatureVerification; |
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.
Keep this one to true (for your test you can definitely disable it, but please don't commit it)