Skip to content

Commit 7005936

Browse files
committed
fix: not lose SOL and SP balances after refresh
1 parent f140c48 commit 7005936

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/components/AccountList/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ReactComponent as SolanaToken } from './assets/solana-token.svg';
1111
import { ReactComponent as SpToken } from './assets/sp-token.svg';
1212
import PassportInfo from '../PassportInfo';
1313
import SelectActivePassportPopup from '../SelectActivePassportPopup';
14-
import { refreshSolanaBalances } from '../../services/wallets';
14+
import { refreshSolanaBalances, storeSystemData } from '../../services/wallets';
1515
import { CoNET_Data } from '../../utils/globals';
1616

1717
interface AccountListProps {
@@ -63,6 +63,8 @@ export default function AccountList({ showMainWallet = true, simplifiedView = fa
6363
try {
6464
await refreshSolanaBalances(profiles?.[1]);
6565

66+
storeSystemData();
67+
6668
const tmpData = CoNET_Data;
6769

6870
if (!tmpData) {

src/services/listeners.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ const getProfileAssets = async (profile: profile, solanaProfile: profile) => {
173173
}
174174

175175
if (solanaProfile.tokens?.sol) {
176-
solanaProfile.tokens.sol.balance = sol === false ? "" : sol?.toFixed(6);
176+
solanaProfile.tokens.sol.balance =
177+
sol === false ? solanaProfile.tokens.sol.balance : sol?.toFixed(6);
177178
} else {
178179
solanaProfile.tokens.sol = {
179180
balance: sol === false ? "" : sol?.toFixed(6),
@@ -186,7 +187,9 @@ const getProfileAssets = async (profile: profile, solanaProfile: profile) => {
186187

187188
if (solanaProfile.tokens?.sp) {
188189
solanaProfile.tokens.sp.balance =
189-
sp === false ? "" : parseFloat(sp).toFixed(6);
190+
sp === false
191+
? solanaProfile.tokens.sp.balance
192+
: parseFloat(sp).toFixed(6);
190193
} else {
191194
solanaProfile.tokens.sp = {
192195
balance: sp === false ? "" : parseFloat(sp).toFixed(6),

src/services/wallets.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const createOrGetWallet = async (secretPhrase: string | null) => {
146146

147147
storeSystemData();
148148

149-
const profiles = CoNET_Data.profiles[0];
149+
const profiles = CoNET_Data.profiles;
150150

151151
return profiles;
152152
};
@@ -594,7 +594,8 @@ const refreshSolanaBalances = async (solanaProfile: profile) => {
594594
]);
595595

596596
if (solanaProfile.tokens?.sol) {
597-
solanaProfile.tokens.sol.balance = sol === false ? "" : sol?.toFixed(6);
597+
solanaProfile.tokens.sol.balance =
598+
sol === false ? solanaProfile.tokens.sol.balance : sol?.toFixed(6);
598599
} else {
599600
solanaProfile.tokens.sol = {
600601
balance: sol === false ? "" : sol?.toFixed(6),
@@ -607,7 +608,9 @@ const refreshSolanaBalances = async (solanaProfile: profile) => {
607608

608609
if (solanaProfile.tokens?.sp) {
609610
solanaProfile.tokens.sp.balance =
610-
sp === false ? "" : parseFloat(sp).toFixed(6);
611+
sp === false
612+
? solanaProfile.tokens.sp.balance
613+
: parseFloat(sp).toFixed(6);
611614
} else {
612615
solanaProfile.tokens.sp = {
613616
balance: sp === false ? "" : parseFloat(sp).toFixed(6),

0 commit comments

Comments
 (0)