Skip to content

🐛 Persist active wallet #657

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
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

IYTEC
Copy link
Contributor

@IYTEC IYTEC commented Jul 29, 2022

ℹ Overview

Persist active wallet address

📝 Related Issues

🔐 Acceptance:

  • yarn test passes
  • Uses Unicode conventional commits gitmoji

@IYTEC IYTEC requested a review from ericsharma July 29, 2022 18:52
@vercel
Copy link

vercel bot commented Jul 29, 2022

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

Name Status Preview Updated
algodex-react-dev ✅ Ready (Inspect) Visit Preview Jul 29, 2022 at 6:54PM (UTC)


// Set Active Wallet when page renders
useEffect(() => {
const activeWallet = JSON.parse(localStorage.getItem('activeWallet'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does JSON.parse work on a null string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it doesn't work on null string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, if there are no activeWallet, it just returns null. Nothing to set

Copy link
Collaborator

Choose a reason for hiding this comment

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

@IYTEC I like what you are doing but I am going to hold off merging this in because I do see some edge-cases with this implementation. Perhaps next week we can get hop on a call and talk about it. But for one thing, setActiveWallet() will throw an error some of the time because the actual hook is setting the wallet on the Algodex Api instance. Since it is internally going through our API it will be subject to AJV schema validation and will throw errors when passed an empty object.


// Set Active Wallet when page renders
useEffect(() => {
const activeWallet = JSON.parse(localStorage.getItem('activeWallet'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@IYTEC I like what you are doing but I am going to hold off merging this in because I do see some edge-cases with this implementation. Perhaps next week we can get hop on a call and talk about it. But for one thing, setActiveWallet() will throw an error some of the time because the actual hook is setting the wallet on the Algodex Api instance. Since it is internally going through our API it will be subject to AJV schema validation and will throw errors when passed an empty object.

useEffect(() => {
const activeWallet = JSON.parse(localStorage.getItem('activeWallet'))
if (activeWallet) {
setActiveWallet(activeWallet)
Copy link
Collaborator

@ericsharma ericsharma Jul 29, 2022

Choose a reason for hiding this comment

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

@IYTEC I actually think that all we would need to do to avoid the edge case would be to check the return
const activeWallet = JSON.parse(localStorage.getItem('activeWallet')) and only call setActiveWallet(activeWallet) when it isn't an empty object. Great work either way! Lets take the weekend to think about it but we can probably merge this in with minimal tweaking on Monday 🕺

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! No problem, we will go through it on Monday

@atrefonas
Copy link
Contributor

@IYTEC @ericsharma what's the status on this?

@IYTEC
Copy link
Contributor Author

IYTEC commented Aug 4, 2022

@atrefonas I'm working on this. Had a meeting with @ericsharma on what the issue was, working on it today.

Base automatically changed from issue-500-✨_Feature_PlaceOrder_v2 to next3 August 5, 2022 15:03
@atrefonas
Copy link
Contributor

Is this PR still needed or is it old and should be closed?

@ericsharma
Copy link
Collaborator

@atrefonas It is old but is a feature that we will eventually want to include in next3. In a prior meeting we discussed this issue and ranked it as low priority for the merge with development. It is something we will work on afterwards so I think it is best to keep it open for now.

@IYTEC
Copy link
Contributor Author

IYTEC commented Sep 7, 2022

@atrefonas, we plan to add this after the merge, just like @ericsharma mentioned.

Base automatically changed from next3 to development October 10, 2022 19:09
Copy link
Contributor

@atrefonas atrefonas left a comment

Choose a reason for hiding this comment

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

As mentioned in the other PR, before making further wallet changes, we first need to:

  1. Move all wallet hooks into algodex-react
  2. Switch to a useReducer and do all the state changes in one place

The wallet code is currently unmanageable in the current state IMO.

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.

3 participants