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

chore: demo redundancy of recursive account balance lookup #5945

Closed
wants to merge 1 commit into from

Conversation

pete-watters
Copy link
Contributor

@pete-watters pete-watters commented Nov 8, 2024

In my investigations into account restore I found that:

  • we run recurseAccountsForActivity however it never actually does any account creation
  • all accounts are created at the start via a check for legacyAccountActivityLookup !== 0

I tested this with a few different wallets:

  • my own (3 accounts)
  • leather dev wallet
  • other account with 400 wallets

Just opening this draft to demonstrate recurseAccountsForActivity is not working as we would expect.

// // TODO: add inscription check here also?
// return hasStxBalance || hasNames || hasBtcBalance;
// },
// }).then(recursiveActivityIndex => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bug in this code seems to be that recursiveActivityIndex is actually returning the most recent account from checkForMostRecentAccount.

@@ -109,8 +118,10 @@ function setWalletEncryptionPassword(args: {
encryptedSecretKey,
})
);
if (legacyAccountActivityLookup !== 0)
if (legacyAccountActivityLookup !== 0) {
// debugger;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As legacyAccountActivityLookup !== 0 all accounts are created here on first load before recurseAccountsForActivity continues

@kyranjamie
Copy link
Collaborator

I don't see a problem here. With dev account, the promise does resolve.

image

In this instance, the legacy look up and the recursive look up are the same, so we call the restoreAccountIndex action later on . The extension works differently to the mobile wallet. We're not supposed to be generating accounts here. We just need to know—and save in the state—what the highest known account index is. With that information, the app elsewhere generates the accounts.

The fact that Gaia and the recursive look up have the same value is good, that means that it works. If you remove all the gaia look/legacy account look up code, and the condition on L105, then the recursive look up will set that value, and the wallet will generate.

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