How to use the @hathor/wallet-lib.storage function in @hathor/wallet-lib

To help you get started, we’ve selected a few @hathor/wallet-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HathorNetwork / hathor-wallet / src / App.js View on Github external
addressesLoadedUpdate = (data) => {
    // Update the version of the wallet that the data was loaded
    hathorLib.storage.setItem('wallet:version', VERSION);

    // Check api version everytime we load address history
    version.checkApiVersion();

    // Update redux with loaded data
    store.dispatch(dataLoaded({ addressesFound: data.addressesFound, transactionsFound: Object.keys(data.historyTransactions).length }));
  }
github HathorNetwork / hathor-wallet / src / utils / wallet.js View on Github external
afterLoadAddressHistory() {
    store.dispatch(loadingAddresses(false));
    const data = hathorLib.wallet.getWalletData();
    // Update historyTransactions with new one
    const historyTransactions = 'historyTransactions' in data ? data['historyTransactions'] : {};
    const allTokens = 'allTokens' in data ? data['allTokens'] : [];
    const transactionsFound = Object.keys(historyTransactions).length;

    const address = hathorLib.storage.getItem('wallet:address');
    const lastSharedIndex = hathorLib.storage.getItem('wallet:lastSharedIndex');
    const lastGeneratedIndex = hathorLib.wallet.getLastGeneratedIndex();

    store.dispatch(historyUpdate({historyTransactions, allTokens, lastSharedIndex, lastSharedAddress: address, addressesFound: lastGeneratedIndex + 1, transactionsFound}));
  },
github HathorNetwork / hathor-wallet / src / App.js View on Github external
import version from './utils/version';
import wallet from './utils/wallet';
import { connect } from "react-redux";
import RequestErrorModal from './components/RequestError';
import DashboardTx from './screens/DashboardTx';
import DecodeTx from './screens/DecodeTx';
import PushTx from './screens/PushTx';
import { dataLoaded, isOnlineUpdate } from "./actions/index";
import store from './store/index';
import createRequestInstance from './api/axiosInstance';
import hathorLib from '@hathor/wallet-lib';
import { DEFAULT_SERVER, VERSION } from './constants';
import LocalStorageStore  from './storage.js';

hathorLib.network.setNetwork('mainnet');
hathorLib.storage.setStore(new LocalStorageStore());

// set default server to bravo testnet
hathorLib.wallet.setDefaultServer(DEFAULT_SERVER);

const mapDispatchToProps = dispatch => {
  return {
    dataLoaded: (data) => dispatch(dataLoaded(data)),
    isOnlineUpdate: (data) => dispatch(isOnlineUpdate(data)),
  };
};

const mapStateToProps = (state) => {
  return {
    isVersionAllowed: state.isVersionAllowed,
    loadingAddresses: state.loadingAddresses,
  };
github HathorNetwork / hathor-wallet / src / utils / wallet.js View on Github external
        (key) => scope.setExtra(key, hathorLib.storage.getItem(key))
      )
github HathorNetwork / hathor-wallet / src / utils / tokens.js View on Github external
saveTokenRedux(uid) {
    const storageTokens = hathorLib.storage.getItem('wallet:tokens');
    store.dispatch(newTokens({tokens: storageTokens, uid: uid}));
  },