-
Notifications
You must be signed in to change notification settings - Fork 37
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
Feature: Implement wallet connection for Stellar #77
base: main
Are you sure you want to change the base?
Conversation
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.
It doesn't satisfy what was asked in the issue.
.env.local
Outdated
@@ -0,0 +1,20 @@ | |||
NEXT_PUBLIC_DISCORD_CLIENT_ID=xxx |
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.
Don't commit your env file
|
||
import { connect as starknetConnect, disconnect as starknetDisconnect } from "starknetkit"; | ||
// Import Stellar SDK (you'll need to add this dependency) | ||
import StellarSdk from "stellar-sdk"; |
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.
You import libraries but do not install them...
Or you forgot to push your package.json
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.
And you don't even use it
|
||
async function stellarConnect() { | ||
console.log("Connecting to Stellar wallet..."); | ||
const wallet = { address: "stellar-wallet-address" }; // Mock example |
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.
Do not mock it, the aim of this issue is to actually implement a stellar wallet
Dear @Marchand-Nicolas I have already made the commit for the changes |
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.
Some code to clean. I will test the feature tomorrow
configs/networks.json
Outdated
@@ -2,11 +2,21 @@ | |||
{ | |||
"name": "mainnet", | |||
"url": "starknetid-mainnet.starknet.a5a.ch", | |||
"indexer": true |
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.
Please don’t delete the indexer field
@@ -288,7 +288,7 @@ export const handleConfigConfirmCommand = async ( | |||
discordServerId: interaction.guildId, | |||
starkyModuleConfig: currentConfig.moduleConfig, | |||
discordRoleId: currentConfig.roleId, | |||
starknetNetwork: currentConfig.network, | |||
//starknetNetwork: currentConfig.network, |
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.
Why ? And don't comment code you don't use anymore, just delete. Else we will end up with comments everywhere
discord/interactions/debugUser.ts
Outdated
@@ -66,7 +66,7 @@ export const handleDebugUserCommand = async ( | |||
const network = discordMember.starknetNetwork as NetworkName; | |||
const discordServerConfigs = await DiscordServerConfigRepository.findBy({ | |||
discordServerId: guildId, | |||
starknetNetwork: network, | |||
//starknetNetwork: network, |
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.
Same
indexer/indexer.ts
Outdated
@@ -22,14 +22,14 @@ const launchIndexers = () => { | |||
const blockStack = new BlockStack(); | |||
// For each network, launch an indexer | |||
for (let network of networks) { | |||
if (network.indexer === true) { | |||
/*if (network.indexer === true) { |
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.
Same
indexer/processBlocks.ts
Outdated
@@ -28,7 +28,7 @@ const processBlocks = async (stack: BlockStack) => { | |||
if (!walletAddress) continue; | |||
const discordConfigs = await DiscordServerConfigRepository.findBy({ | |||
discordServerId: member.discordServerId, | |||
starknetNetwork: networkName, | |||
//starknetNetwork: networkName, |
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.
Same
utils/discord/refreshRoles.ts
Outdated
@@ -58,7 +58,7 @@ export const refreshDiscordMemberForAllConfigs = async ( | |||
const network = discordMember.starknetNetwork as NetworkName; | |||
const discordServerConfigs = await DiscordServerConfigRepository.findBy({ | |||
discordServerId: discordMember.discordServerId, | |||
starknetNetwork: network, | |||
// starknetNetwork: network, |
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.
Same
I have already fixed, could you check again please |
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.
Still a lot of problems.
The code is not really clean...
You should install a linter, and take time to read your code. You'll learn a lot if you try reviewing it yourself before pushing.
I haven't tested the feature yet, will do it asap
.env.local.sample
Outdated
@@ -1,21 +0,0 @@ | |||
NEXT_PUBLIC_DISCORD_CLIENT_ID=xxx |
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.
Please don't touch this file.
Eqverytime, before requesting a review, please check here #77 that you didn't do anything wrong
sepolia: string; | ||
}; | ||
|
||
const chainIds: ChainIds = { |
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.
Why adding this variable ? It's not used
signMessage: (message: any) => Promise<Signature>; | ||
}; | ||
|
||
type StarknetAccount = { |
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.
Do not define types here, it's not clean. If you want to define types (other than Props), define them in the folder types
|
||
useEffect(() => { | ||
const fetchNetworkConfig = async () => { | ||
const response = await fetch("/configs/networks.json"); |
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.
If you want to access the config, just import it, do not fetch it
}; | ||
const signature = await account.signMessage(messageCopy); | ||
await verifySignature(signature); | ||
let signature; |
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.
this variable is not used
domain: { ...messageToSign.domain, chainId }, | ||
}; | ||
signature = messageCopy; | ||
} | ||
} catch (e: any) { | ||
WatchTowerLogger.error(e.message, e); | ||
} | ||
}, [account, verifySignature, chainId]); |
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.
React Hook useCallback has an unnecessary dependency: 'verifySignature'. Either exclude it or remove the dependency array.
Also there are still conflicts, so I can't merge |
Hi Marchand-Nicolas, I have run the project before, but it shows me errors from the last merges, may be the conflicts come because of it, now I will clean the code, sorry I am learning, it's my first time on how to apply the connection wallet for Stellar, I just want learn and help, regards |
.env.local.sample
Outdated
@@ -1,21 +0,0 @@ | |||
NEXT_PUBLIC_DISCORD_CLIENT_ID=xxx |
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.
Please do not delete this file
configs/chainAliasByNetwork.json
Outdated
@@ -1,5 +1,7 @@ | |||
{ | |||
"goerli": ["SN_GOERLI", "0x534e5f474f45524c49"], | |||
"sepolia": ["SN_SEPOLIA", "0x534e5f5345504f4c4941"], | |||
"mainnet": ["SN_MAIN", "0x534e5f4d41494e"] | |||
"mainnet": ["SN_MAIN", "0x534e5f4d41494e"], | |||
"stellar-mainnet": ["SN_STELLAR_MAIN", "0x534e5f53544c4c41524d41494e"], |
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.
Rename ST_MAIN and ST_TEST instead of SN_xxx for Stellar
configs/networks.json
Outdated
{ | ||
"name": "stellar-mainnet", | ||
"url": "stellar-mainnet-url", | ||
"indexer": true, |
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.
Set indexer to false for stellar because we currently don't have one for these networks
@@ -16,7 +16,12 @@ export class DiscordServerConfig { | |||
discordServerId: string; | |||
|
|||
@Column() | |||
starknetNetwork: "goerli" | "mainnet" | "sepolia"; | |||
starknetNetwork: |
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.
Perfect!
@@ -14,6 +14,8 @@ | |||
"@apibara/protocol": "^0.4.8", | |||
"@apibara/starknet": "^0.3.0", | |||
"@discordjs/rest": "^2.1.0", | |||
"@stellar/freighter-api": "^4.0.0", |
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 imports look good too well done
signMessage: (message: any) => Promise<Signature>; | ||
}; | ||
|
||
type StarknetAccount = { |
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.
Please apply this comment https://github.com/nmalzieu/starky/pull/77/files#r1937105706
|
||
useEffect(() => { | ||
const fetchNetworkConfig = async () => { | ||
const response = await fetch("/configs/networks.json"); |
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.
Please apply this comment https://github.com/nmalzieu/starky/pull/77/files#r1937107018
On it |
Done, please review |
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.
); | ||
|
||
useEffect(() => { | ||
const fetchNetworkConfig = async () => { |
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.
Don't fetch the config. Import it
Let me fix it |
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.
7️⃣ Create a Pull Request for issue #52 (PR)
! Changes
Add Stellar Testnet and Stellar Mainnet to configs/networks.json with the new "chain" field
Update pages/verify/[discordServerId]/[discordMemberId]/[customLink].tsx
Create separate reusable functions/components for starknetWallet and stellarWallet
Thank you for review this PR ✨
close: #52