Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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 })
}
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
}
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 })
}
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 })
}
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 })
}
}
.then((amount) => {
cacheStorageSet('currencyBalances', `qtum_${address}`, amount, 30)
reducers.user.setBalance({ name: 'qtumData', amount })
return amount
})
.catch((err) => {
const getRate = async () => {
const exCurrencyRate = await actions.user.getExchangeRate('BTC', 'usd')
reducers.user.setCurrencyRate({ name: 'btcData', currencyRate: exCurrencyRate })
}
const login = async (accountName, activePrivateKey, activePublicKey) => {
reducers.user.setAuthData({ name: 'eosData', data: { activePrivateKey, activePublicKey, address: accountName } })
}
.catch((e) => {
reducers.user.setBalanceError({ name: 'ethData' })
})
}
}).then(({ balance, unconfirmedBalance }) => {
reducers.user.setBalance({ name: dataKey, amount: balance, unconfirmedBalance })
return balance
})
.catch((e) => {