Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Commit d9c7878

Browse files
committed
solution: fix incorrect blockchain when subscribing balance
1 parent a72a674 commit d9c7878

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

packages/store/src/accounts/sagas.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function* createHdAddress(vault: IEmeraldVault, action: ICreateHdEntry): SagaIte
160160
}
161161

162162
if (existingAccount == null) {
163-
console.error(`Wallet ${wallet.id} doesn't have HD account`);
163+
console.error(`Wallet ${walletId} doesn't have HD account`);
164164

165165
return;
166166
}
@@ -210,9 +210,11 @@ function* createHdAddress(vault: IEmeraldVault, action: ICreateHdEntry): SagaIte
210210
const tokens = tokenRegistry.byBlockchain(blockchain);
211211

212212
if (blockchain === BlockchainCode.ETC || blockchain === BlockchainCode.ETH) {
213+
const shadowBlockchain = blockchain === BlockchainCode.ETH ? BlockchainCode.ETC : BlockchainCode.ETH;
214+
213215
const addShadowEntry = {
214216
...addEntry,
215-
blockchain: blockchainCodeToId(blockchain === BlockchainCode.ETH ? BlockchainCode.ETC : BlockchainCode.ETH),
217+
blockchain: blockchainCodeToId(shadowBlockchain),
216218
};
217219

218220
const shadowEntryId = yield call(vault.addEntry, walletId, addShadowEntry);
@@ -226,10 +228,10 @@ function* createHdAddress(vault: IEmeraldVault, action: ICreateHdEntry): SagaIte
226228
if (shadowEntry?.address?.value != null) {
227229
const { value: shadowAddress } = shadowEntry.address;
228230

229-
ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, blockchain, shadowEntryId, [shadowAddress]);
231+
ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, shadowBlockchain, shadowEntryId, [shadowAddress]);
230232

231-
yield put(requestTokensBalances(blockchain, tokens, shadowAddress));
232-
yield put(hdAccountCreated(wallet.id, shadowEntry));
233+
yield put(requestTokensBalances(shadowBlockchain, tokens, shadowAddress));
234+
yield put(hdAccountCreated(walletId, shadowEntry));
233235
}
234236
}
235237

@@ -238,9 +240,9 @@ function* createHdAddress(vault: IEmeraldVault, action: ICreateHdEntry): SagaIte
238240
ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, blockchain, entry.id, [entryAddress]);
239241

240242
yield put(requestTokensBalances(blockchain, tokens, entryAddress));
241-
yield put(hdAccountCreated(wallet.id, entry));
243+
yield put(hdAccountCreated(walletId, entry));
242244

243-
yield put(screen.actions.gotoScreen(screen.Pages.WALLET, wallet.id));
245+
yield put(screen.actions.gotoScreen(screen.Pages.WALLET, walletId));
244246
} catch (error) {
245247
if (error instanceof Error) {
246248
yield put(screen.actions.showError(error));

0 commit comments

Comments
 (0)