Skip to content
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

make getProofsToSend more robust to refreshes #123

Merged
merged 2 commits into from
Oct 31, 2024
Merged

Conversation

gudnuf
Copy link
Contributor

@gudnuf gudnuf commented Oct 30, 2024

There was a potential loss of funds from the time that createSendableToken was called to when the calling function completed sending if, for example, the user refreshed the page while the sendable proofs were only in memory.

I attempted to resolve this by storing the freshly created proofs back in localstorage, then removing them once they are either spent or saved elsewhere (ie. transaction history or database)

Copy link

vercel bot commented Oct 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
boardwalk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 2:14pm

@@ -540,28 +554,35 @@ export const useCashu = () => {
dispatch(setSending('Sending...'));

try {
const proofsToSend = await getProofsToSend(
const proofsToSend = getProofsByAmount(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was causing an unnecessary swap. Instead, we can just get the change from the wallet.meltTokens response.

Copy link
Collaborator

@jbojcic1 jbojcic1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this enough yet to give a meaningful review so I'll just approve now. It's still useful to have the PR to keep an eye on whats going on.

I'll try to go through the code on a deeper level once I understand cashu better.

@gudnuf gudnuf merged commit 14e5ebf into main Oct 31, 2024
2 checks passed
@gudnuf gudnuf deleted the fix/refresh-on-send-token branch October 31, 2024 09:33
gudnuf added a commit that referenced this pull request Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants