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

refactor!: migrate from .afj to .credo #2161

Conversation

sairanjit
Copy link
Contributor

@sairanjit sairanjit commented Jan 28, 2025

Summary

Questions

  • Do we need to delete the .afj folder or old wallet after migrating to .credo folder ?

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Copy link

changeset-bot bot commented Jan 28, 2025

⚠️ No Changeset found

Latest commit: b3c1f86

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sairanjit sairanjit changed the title refactor!: migrate wallet from .afj to .credo refactor!: migrate from .afj to .credo Jan 28, 2025
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
@sairanjit
Copy link
Contributor Author

cc: @TimoGlastra @genaris

@sairanjit
Copy link
Contributor Author

I have tested on node and Android

Screenshot 2025-01-29 at 5 24 47 PM

@sairanjit sairanjit marked this pull request as ready for review January 29, 2025 12:01
@sairanjit sairanjit requested a review from a team as a code owner January 29, 2025 12:01
@TimoGlastra
Copy link
Contributor

Thanks for this PR @sairanjit, I think it would be good to wait for a bit with releasing this, as it makes testing with 0.6 unstable versions easier (due to that a migration script can only be run once per version). We should probably look into multi-updates at some point

* Migrate data from .afj to .credo if .afj exists.
* Copy the contents from old directory (.afj) to new directory (.credo).
*/
public async migrateWalletToCredoFolder(walletId: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the file system should stay very generic. So instead of adding this method migrateWalletToCredoFolder in the file system (which then needs to be implemented by every file system), I'd move it to the migration method. This can then call the needed methods exists and copyDirectory (i think this method can also copy files now? Should we create one generic copy method that can do both directories (using recursive property) and files?)

Comment on lines +62 to +67
for await (const path of pathsToMigrate) {
// Migrate if the old paths exist
if (await this.exists(path.from)) {
await this.copyDirectory(path.from, path.to)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we delete the old files afterwards? Or how do we clean up?

* Migrate data from .afj to .credo if .afj exists.
* Copy the contents from old directory (.afj) to new directory (.credo).
*/
public async migrateWalletToCredoFolder() {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, this can be moved to migration logic so we don't have to duplicate

* Migrates the sqlite folder location from .afj to .credo in the storage directory in node and react native.
*
*/
export async function migrateToCredoFolder<Agent extends BaseAgent>(agent: Agent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

due to the sensivity in doing migrations it's always good to test these migrations extensively. For all other migrations and version changes we have tests (per migration method, and for a version migration in general), can you add these?

Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

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

One thing I'm not sure about is how this works:

  • We initialize the agent and open the wallet (this will use the new paths, so a new wallet will be created)
  • The wallet will be initialized with storage version 0.6
  • No updates need to happen because we're on the new path
  • we now have a new empty wallet

Or am i missing something here?

@sairanjit
Copy link
Contributor Author

Based on the discussion in the Credo Contributors meeting on 30th January 2025 we can keep .afj folder due to the complexity involved in the #1715 and close this PR

@sairanjit sairanjit closed this Jan 30, 2025
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.

Migrate from .afj data folder to .credo
2 participants