Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

add svelte wallet example #3408

Closed
xcaptain opened this issue Oct 21, 2024 · 9 comments
Closed

add svelte wallet example #3408

xcaptain opened this issue Oct 21, 2024 · 9 comments
Labels
enhancement New feature or request question Add this to close an issue with instructions on how to repost as a question on Stack Exchange

Comments

@xcaptain
Copy link

I want to use web3.js v2 in my sveltekit app, but you only provide react example app, could you provide an official svelte wallet example app?

I have originally posted my question at anza-xyz/wallet-adapter#1027 but no one answers. So I followed the react demo app made a simple sveltekit app.

source code: https://github.com/xcaptain/solana-wallet-demo
demo website: https://solana-wallet-demo.pages.dev/

If welcome, I can make a pull request to submit this demo app

@xcaptain xcaptain added the enhancement New feature or request label Oct 21, 2024
@xcaptain
Copy link
Author

xcaptain commented Oct 22, 2024

for (const wallet of wallets) {
if (wallet.name === savedWalletName) {
for (const account of wallet.accounts) {
if (account.address === savedAccountAddress) {
return account;

The localStorage in the react-app is not working, because useWallets() doesn't returns accounts

image

so everytime refresh browser, I will be recgonized as not connected

image

@steveluscher can you take a look at this?

Above debug info was found at: https://solana-labs.github.io/solana-web3.js/example/

@xcaptain
Copy link
Author

I have a workaround to solve the problem when loading walletAccount from localStorage wallet accounts is empty.

https://github.com/xcaptain/solana-wallet-demo/blob/281a8d421aeeb26307cd225706ce2bc3ab4e7988/src/routes/%2Bpage.svelte#L138-L150

this walletAccount can't be used to sign and send transaction, so to send transaction, must connect again

https://github.com/xcaptain/solana-wallet-demo/blob/281a8d421aeeb26307cd225706ce2bc3ab4e7988/src/routes/%2Bpage.svelte#L247-L251

@steveluscher
Copy link
Contributor

  1. This GitHub is not suitable for technical support. I will paste in the link for that at the bottom – please re-ask your question about wallet autoconnecting there, paste the link here, and I will answer it.
  2. The @solana/web3.js repository is not meant to warehouse a compendium of framework examples, but you should feel free to make one, and to find the most authoritative awesome- list that you can, to have it added there! If you find a particularly good list of example apps, consider sending us a pull request to have it linked to from our examples/README.md.

@steveluscher steveluscher closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
@steveluscher steveluscher added the question Add this to close an issue with instructions on how to repost as a question on Stack Exchange label Oct 22, 2024
Copy link
Contributor

Hi @xcaptain,

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of the Solana JavaScript SDK itself.

Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with the Solana JavaScript SDK itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask


This automated message is a result of having added the ‘question’ tag.

@xcaptain
Copy link
Author

Well, 3 days ago it's a question because I don't know how to implement a wallet button in svelte, but now I know it and made a workable demo app and I think there is a bug in the react-app because localStorage is not working, after refresh browser my last used wallet account doesn't show up.

@steveluscher
Copy link
Contributor

…I think there is a bug in the react-app because localStorage is not working, after refresh browser my last used wallet account doesn't show up.

It is a bug, but not in the way you might think. Throw up a question on Stack Exchange, and I'll answer it there so that the entire community of Solana developers can benefit from the answer going in to the future.

@xcaptain
Copy link
Author

I posted my question at: https://solana.stackexchange.com/questions/17070/how-to-implement-a-wallet-button-using-web3-js-v2

I have some basic understandings to web3.js, but need someone to help me sort out my thoughts

@steveluscher
Copy link
Contributor

That post asks too many questions at once. If you ask one question at a time, it's more likely to get answered. If you want to post one just asking why accounts is empty for a previously connected wallet upon refresh, I'll be happy to lay out the answer there.

Sorry to be pedantic, and not just answer it here. It's important.

Copy link
Contributor

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request question Add this to close an issue with instructions on how to repost as a question on Stack Exchange
Projects
None yet
Development

No branches or pull requests

2 participants