Skip to content

Commit

Permalink
fix: adjusts tokens utils store reader
Browse files Browse the repository at this point in the history
  • Loading branch information
tuliomir committed Apr 9, 2024
1 parent 652d2cb commit 49c41d6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/utils/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { newTokens, removeTokenMetadata } from '../actions/index';
import wallet from './wallet';
import hathorLib from '@hathor/wallet-lib';
import LOCAL_STORE from '../storage';
import { getGlobalWallet } from "../services/wallet.service";

/**
* Methods to create and handle tokens
Expand Down Expand Up @@ -56,12 +57,11 @@ const tokens = {
* @inner
*/
async addToken(uid, name, symbol) {
const reduxState = store.getState();
const reduxWallet = reduxState.wallet;
await reduxWallet.storage.registerToken({ uid, name, symbol });
const tokens = await this.getRegisteredTokens(reduxWallet);
const globalWallet = getGlobalWallet();
await globalWallet.storage.registerToken({ uid, name, symbol });
const tokens = await this.getRegisteredTokens(globalWallet);
store.dispatch(newTokens({tokens, uid: uid}));
wallet.fetchTokensMetadata([uid], reduxWallet.conn.network);
wallet.fetchTokensMetadata([uid], globalWallet.conn.network);
},

/**
Expand All @@ -75,10 +75,9 @@ const tokens = {
* @inner
*/
async unregisterToken(uid) {
const reduxState = store.getState();
const reduxWallet = reduxState.wallet;
await reduxWallet.storage.unregisterToken(uid);
const tokens = await this.getRegisteredTokens(reduxWallet);
const globalWallet = getGlobalWallet();
await globalWallet.storage.unregisterToken(uid);
const tokens = await this.getRegisteredTokens(globalWallet);
store.dispatch(newTokens({tokens, uid: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid}));
store.dispatch(removeTokenMetadata(uid));
},
Expand Down

0 comments on commit 49c41d6

Please sign in to comment.