apps
apps copied to clipboard
Add capability to export/import accounts / address book
Migrating to a new computer (or new browser) when using Polkadot-JS is a bit time-consuming.
Ideally there should be a way to export an address book into a JSON or similar file, and load in to a new browser.
Support should be done in the same way as in the extension.
Hey @jacogr , I hacked around and put together instructions on migrating accounts via exporting local storage and re-importing on the new computer. Can you take a look at it to see if I am missing anything?
https://hackmd.io/BRofZxIKT1yTOt0MQvJrQA
Seems sane. Not sure about this part val = JSON.stringify(accounts[key]).replace(/\\/g,'').slice(1,-1);
specifically the replace, not sure where those slip in in the process.
I believe it would probably work with another parse, i.e. val = JSON.parse(accounts[key])
instead of the above
The ""'s occur as a result of the initial JSON.stringify when exporting (escaping the " characters). But you need to get rid of them before putting the string into storage, otherwise Polkadot-JS can't parse it (get some error messages when it tries to read them).
Using another JSON.parse doesn't work here because then they get stored as an actual JSON object (instead of a string) in storage. I had to ensure that it got stored as string and matched the format of the strings stored (thus the slice, when I initially tried to store them it kept the initial " characters, which do not match the format of the other stored addresses).