-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Wallet-Based Authentication with Stellar Wallet Kit (#20)
* integrated the stellar wallet * added functions for register and login with wallet * added connect wallet function for login with wallet button * updated changes as requested in review * added compoent for the wallet component * updated the changes with the requested changes * removed imports not needed * adjusted the code according to previous review * removed yarn lock file * refactor(walletStore): clean up code and improve transaction signing logic * feat: update stellar-wallets-kit dependency and enhance wallet user confirmation flow * refactor(walletStore): simplify network type assignment in wallet creation --------- Co-authored-by: Elliot Voris <[email protected]>
- Loading branch information
1 parent
7b2b921
commit 407e19a
Showing
8 changed files
with
1,600 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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 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 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,42 @@ | ||
<!-- src/lib/components/WalletComponent.svelte --> | ||
<script> | ||
import { goto } from '$app/navigation'; | ||
import { walletStore } from '$lib/stores/walletStore'; | ||
// @ts-ignore | ||
import { StellarWalletsKit, WalletNetwork, allowAllModules, XBULL_ID } from '@creit.tech/stellar-wallets-kit' | ||
export let buttonText = 'Connect Wallet'; | ||
const kit = new StellarWalletsKit({ | ||
network: WalletNetwork.TESTNET, | ||
selectedWalletId: XBULL_ID, | ||
modules: allowAllModules(), | ||
}); | ||
const connectWallet = async () => { | ||
try { | ||
await kit.openModal({ | ||
// @ts-ignore | ||
onWalletSelected: async (option) => { | ||
kit.setWallet(option.id); | ||
const { address } = await kit.getAddress(); | ||
if (address) { | ||
await walletStore.connectWallet({ publicKey: address }); | ||
goto('/dashboard'); | ||
} | ||
} | ||
}); | ||
} catch (error) { | ||
console.error('Error connecting wallet:', error); | ||
} | ||
}; | ||
export { connectWallet }; | ||
</script> | ||
|
||
<!-- You can provide a button or any UI elements if needed --> | ||
<button type="button" class="btn-secondary btn" on:click={connectWallet}> | ||
{buttonText} | ||
</button> |
This file contains 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 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 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 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
Oops, something went wrong.