How to use the redux/core/reducers.user function in redux

To help you get started, we’ve selected a few redux 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 swaponline / swap.react / shared / redux / actions / usdt.js View on Github external
}

  const account     = bitcoin.ECPair.fromWIF(privateKey, btc.network) // eslint-disable-line
  const address     = account.getAddress()
  const publicKey   = account.getPublicKeyBuffer().toString('hex')

  const data = {
    account,
    keyPair,
    address,
    privateKey,
    publicKey,
  }

  console.info('Logged in with USDT', data)
  reducers.user.setAuthData({ name: 'usdtData', data })
}
github swaponline / swap.react / shared / redux / actions / nimiq.js View on Github external
const login = async (ethPrivateKey) => {
  await init()

  $.wallet = await initWallet(ethPrivateKey)

  const data = {
    balance: 0,
    address: $.wallet.address.toUserFriendlyAddress(),
  }

  console.info('Logged in with Nimiq', data)
  reducers.user.setAuthData({ name: 'nimData', data })

  return data
}
github swaponline / swap.react / shared / redux / actions / btcmultisig.js View on Github external
addressOfMyOwnWallet,
    currency: 'BTC (Multisig)',
    fullName: 'Bitcoin (Multisig)',
    privateKey,
    publicKeys,
    publicKey,
  }

  localStorage.setItem(constants.privateKeyNames.btcMultisigOtherOwnerKey, otherOwnerPublicKey)

  
  window.getBtcMultisigData = () => data
  window.getBtcMultisigAddress = () => data.address

  console.info('Logged in with BitcoinMultisig', data)
  reducers.user.setAuthData({ name: 'btcMultisigData', data })
}
github swaponline / swap.react / shared / redux / actions / bch.js View on Github external
const publicKey   = account.getPublicKeyBuffer().toString('hex')

  const data = {
    account,
    keyPair,
    address,
    currency: 'BCH',
    fullName: 'BitcoinCash',
    privateKey,
    publicKey,
  }

  window.getBchAddress = () => data.address

  console.info('Logged in with Bitcoin Cash', data)
  reducers.user.setAuthData({ name: 'bchData', data })
}
github swaponline / swap.react / shared / redux / actions / token.js View on Github external
const getBalance = async (currency) => {
  const { user: { tokensData } } = getState()

  if (currency === undefined) {
    return
  }
  const { address, contractAddress, decimals, name  } = tokensData[currency.toLowerCase()]
  const ERC20 = new web3.eth.Contract(ERC20_ABI, contractAddress)
  try {
    const result = await ERC20.methods.balanceOf(address).call()
    console.log('result get balance', result)
    let amount = new BigNumber(String(result)).dividedBy(new BigNumber(String(10)).pow(decimals)).toString()
    reducers.user.setTokenBalance({ name, amount })
    return amount
  } catch (e) {
    reducers.user.setTokenBalanceError({ name })
  }
}
github swaponline / swap.react / shared / redux / actions / qtum.js View on Github external
.then((amount) => {
      cacheStorageSet('currencyBalances', `qtum_${address}`, amount, 30)
      reducers.user.setBalance({ name: 'qtumData', amount })
      return amount
    })
    .catch((err) => {
github swaponline / swap.react / shared / redux / actions / btcmultisig.js View on Github external
const getRate = async () => {
  const exCurrencyRate = await actions.user.getExchangeRate('BTC', 'usd')
  reducers.user.setCurrencyRate({ name: 'btcData', currencyRate: exCurrencyRate })
}
github swaponline / swap.react / shared / redux / actions / eos.js View on Github external
const login = async (accountName, activePrivateKey, activePublicKey) => {
  reducers.user.setAuthData({ name: 'eosData', data: { activePrivateKey, activePublicKey, address: accountName } })
}
github swaponline / swap.react / shared / redux / actions / eth.js View on Github external
.catch((e) => {
      reducers.user.setBalanceError({ name: 'ethData' })
    })
}
github swaponline / swap.react / shared / redux / actions / btcmultisig.js View on Github external
}).then(({ balance, unconfirmedBalance }) => {
      reducers.user.setBalance({ name: dataKey, amount: balance, unconfirmedBalance })
      return balance
    })
    .catch((e) => {