Skip to content

Commit

Permalink
feat: use cloneDeep to get token data from storage in the get balance
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroferreira1 committed Jan 14, 2025
1 parent 77c24ac commit 49d3ae9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/new/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { get } from 'lodash';
import { cloneDeep, get } from 'lodash';
import bitcore, { HDPrivateKey } from 'bitcore-lib';
import EventEmitter from 'events';
import { NATIVE_TOKEN_UID, P2SH_ACCT_PATH, P2PKH_ACCT_PATH } from '../constants';
Expand Down Expand Up @@ -699,7 +699,9 @@ class HathorWallet extends EventEmitter {
throw new WalletError('Not implemented.');
}
const uid = token || this.token.uid;
let tokenData = await this.storage.getToken(uid);
// Using clone deep so the balance returned will not be updated in case
// we change the storage
let tokenData = cloneDeep(await this.storage.getToken(uid));
if (tokenData === null) {
// We don't have the token on storage, so we need to return an empty default response
tokenData = {
Expand Down

0 comments on commit 49d3ae9

Please sign in to comment.