|
8 | 8 | } from '@emeraldpay/emerald-vault-core'; |
9 | 9 | import { BitcoinEntry, isBitcoinEntry, isEthereumEntry } from '@emeraldpay/emerald-vault-core/lib/types'; |
10 | 10 | import { |
| 11 | + BlockchainCode, |
11 | 12 | Blockchains, |
12 | 13 | IpcCommands, |
13 | 14 | PersistentState, |
@@ -204,14 +205,41 @@ function* createHdAddress(vault: IEmeraldVault, action: ICreateHdEntry): SagaIte |
204 | 205 | return; |
205 | 206 | } |
206 | 207 |
|
207 | | - ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, blockchain, entry.id, [entry.address.value]); |
208 | | - |
209 | 208 | const tokenRegistry = new TokenRegistry(action.tokens); |
210 | 209 |
|
211 | 210 | const tokens = tokenRegistry.byBlockchain(blockchain); |
212 | 211 |
|
213 | | - yield put(requestTokensBalances(blockchain, tokens, entry.address.value)); |
| 212 | + if (blockchain === BlockchainCode.ETC || blockchain === BlockchainCode.ETH) { |
| 213 | + const addShadowEntry = { |
| 214 | + ...addEntry, |
| 215 | + blockchain: blockchainCodeToId(blockchain === BlockchainCode.ETH ? BlockchainCode.ETC : BlockchainCode.ETH), |
| 216 | + }; |
| 217 | + |
| 218 | + const shadowEntryId = yield call(vault.addEntry, walletId, addShadowEntry); |
| 219 | + |
| 220 | + yield call(vault.setEntryReceiveDisabled, shadowEntryId, true); |
| 221 | + |
| 222 | + wallet = yield call(vault.getWallet, walletId); |
| 223 | + |
| 224 | + const shadowEntry = wallet.entries.find(({ id }) => id === shadowEntryId); |
| 225 | + |
| 226 | + if (shadowEntry?.address?.value != null) { |
| 227 | + const { value: shadowAddress } = shadowEntry.address; |
| 228 | + |
| 229 | + ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, blockchain, shadowEntryId, [shadowAddress]); |
| 230 | + |
| 231 | + yield put(requestTokensBalances(blockchain, tokens, shadowAddress)); |
| 232 | + yield put(hdAccountCreated(wallet.id, shadowEntry)); |
| 233 | + } |
| 234 | + } |
| 235 | + |
| 236 | + const { value: entryAddress } = entry.address; |
| 237 | + |
| 238 | + ipcRenderer.send(IpcCommands.BALANCE_SUBSCRIBE, blockchain, entry.id, [entryAddress]); |
| 239 | + |
| 240 | + yield put(requestTokensBalances(blockchain, tokens, entryAddress)); |
214 | 241 | yield put(hdAccountCreated(wallet.id, entry)); |
| 242 | + |
215 | 243 | yield put(screen.actions.gotoScreen(screen.Pages.WALLET, wallet.id)); |
216 | 244 | } catch (error) { |
217 | 245 | if (error instanceof Error) { |
|
0 commit comments