save new wallet

This commit is contained in:
PhilReact 2025-03-05 00:26:10 +02:00 committed by Nicola Benaglia
parent d3af9bf726
commit 36d34a631d

View File

@ -88,10 +88,12 @@ import {
cleanUrl, cleanUrl,
getFee, getFee,
getProtocol, getProtocol,
getWallets,
groupApi, groupApi,
groupApiLocal, groupApiLocal,
groupApiSocket, groupApiSocket,
groupApiSocketLocal, groupApiSocketLocal,
storeWallets,
} from "./background"; } from "./background";
import { import {
executeEvent, executeEvent,
@ -1007,6 +1009,26 @@ function App() {
} }
}; };
const saveWalletToLocalStorage = async (newWallet)=> {
try {
getWallets().then((res)=> {
if(res && Array.isArray(res)){
const wallets = [...res, newWallet]
storeWallets(wallets)
} else {
storeWallets([newWallet])
}
setIsLoading(false)
}).catch((error)=> {
console.error(error)
setIsLoading(false)
})
} catch (error) {
console.error(error)
}
}
const createAccountFunc = async () => { const createAccountFunc = async () => {
try { try {
if (!walletToBeDownloadedPassword) { if (!walletToBeDownloadedPassword) {
@ -1043,6 +1065,7 @@ function App() {
.then((response) => { .then((response) => {
if (response && !response.error) { if (response && !response.error) {
setRawWallet(wallet); setRawWallet(wallet);
saveWalletToLocalStorage(wallet)
setWalletToBeDownloaded({ setWalletToBeDownloaded({
wallet, wallet,
qortAddress: wallet.address0, qortAddress: wallet.address0,