feat: change to generic ERC-20 ABI json file
fix: coinUtils rename import
This commit is contained in:
parent
dff407e30e
commit
8e099e3283
36 changed files with 364 additions and 249 deletions
|
|
@ -4,7 +4,7 @@ const settingsLoader = require('./settings-loader')
|
|||
const configManager = require('./config-manager')
|
||||
const wallet = require('../wallet')
|
||||
const ticker = require('../ticker')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const machineLoader = require('../machine-loader')
|
||||
|
||||
module.exports = {getFunding}
|
||||
|
|
@ -40,14 +40,14 @@ function fetchMachines () {
|
|||
}
|
||||
|
||||
function computeCrypto (cryptoCode, _balance) {
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
return BN(_balance).shift(-unitScale).round(5)
|
||||
}
|
||||
|
||||
function computeFiat (rate, cryptoCode, _balance) {
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
return BN(_balance).shift(-unitScale).mul(rate).round(5)
|
||||
|
|
@ -61,9 +61,9 @@ function getFunding (_cryptoCode) {
|
|||
const cryptoCode = _cryptoCode || cryptoCodes[0]
|
||||
const fiatCode = config.fiatCurrency
|
||||
const pareCoins = c => _.includes(c.cryptoCode, cryptoCodes)
|
||||
const cryptoCurrencies = utils.cryptoCurrencies()
|
||||
const cryptoCurrencies = coinUtils.cryptoCurrencies()
|
||||
const cryptoDisplays = _.filter(pareCoins, cryptoCurrencies)
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
|
||||
if (!cryptoRec) throw new Error(`Unsupported coin: ${cryptoCode}`)
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ function getFunding (_cryptoCode) {
|
|||
const pending = fundingRec.fundingPendingBalance
|
||||
const fiatPending = computeFiat(rate, cryptoCode, pending)
|
||||
const fundingAddress = fundingRec.fundingAddress
|
||||
const fundingAddressUrl = utils.buildUrl(cryptoCode, fundingAddress)
|
||||
const fundingAddressUrl = coinUtils.buildUrl(cryptoCode, fundingAddress)
|
||||
|
||||
return {
|
||||
cryptoCode,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
const path = require('path')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const coinRec = utils.getCryptoCurrency('BTC')
|
||||
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||
|
||||
function setup (dataDir) {
|
||||
common.firewall([coinRec.defaultPort])
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
const path = require('path')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const coinRec = utils.getCryptoCurrency('BCH')
|
||||
const coinRec = coinUtils.getCryptoCurrency('BCH')
|
||||
|
||||
function setup (dataDir) {
|
||||
common.firewall([coinRec.defaultPort])
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
const path = require('path')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const coinRec = utils.getCryptoCurrency('DASH')
|
||||
const coinRec = coinUtils.getCryptoCurrency('DASH')
|
||||
|
||||
function setup (dataDir) {
|
||||
common.firewall([coinRec.defaultPort])
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
function setup (dataDir) {
|
||||
const coinRec = utils.getCryptoCurrency('ETH')
|
||||
const coinRec = coinUtils.getCryptoCurrency('ETH')
|
||||
common.firewall([coinRec.defaultPort])
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} --datadir "${dataDir}" --syncmode="fast" --cache 2048 --maxpeers 40 --rpc`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ const makeDir = require('make-dir')
|
|||
const inquirer = require('inquirer')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const coinUtils = require('../coin-utils')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const blockchainUtils = require('../blockchain-utils')
|
||||
|
||||
const common = require('./common')
|
||||
const doVolume = require('./do-volume')
|
||||
|
||||
const cryptos = utils.cryptoCurrencies()
|
||||
const cryptos = coinUtils.cryptoCurrencies()
|
||||
|
||||
const logger = common.logger
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ const PLUGINS = {
|
|||
module.exports = {run}
|
||||
|
||||
function installedVolumeFilePath (crypto) {
|
||||
return path.resolve(utils.cryptoDir(crypto, coinUtils.blockchainDir()), '.installed')
|
||||
return path.resolve(coinUtils.cryptoDir(crypto, blockchainUtils.blockchainDir()), '.installed')
|
||||
}
|
||||
|
||||
function isInstalledVolume (crypto) {
|
||||
|
|
@ -59,7 +59,7 @@ function processCryptos (codes) {
|
|||
_.forEach(setupCrypto, selectedCryptos)
|
||||
common.es('sudo service supervisor restart')
|
||||
|
||||
const blockchainDir = coinUtils.blockchainDir()
|
||||
const blockchainDir = blockchainUtils.blockchainDir()
|
||||
const backupDir = path.resolve(os.homedir(), 'backups')
|
||||
const rsyncCmd = `( \
|
||||
(crontab -l 2>/dev/null || echo -n "") | grep -v "@daily rsync ".*"wallet.dat"; \
|
||||
|
|
@ -74,7 +74,7 @@ function processCryptos (codes) {
|
|||
|
||||
function setupCrypto (crypto) {
|
||||
logger.info(`Installing ${crypto.display}...`)
|
||||
const cryptoDir = utils.cryptoDir(crypto, coinUtils.blockchainDir())
|
||||
const cryptoDir = coinUtils.cryptoDir(crypto, blockchainUtils.blockchainDir())
|
||||
makeDir.sync(cryptoDir)
|
||||
const cryptoPlugin = plugin(crypto)
|
||||
const oldDir = process.cwd()
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
const path = require('path')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const coinRec = utils.getCryptoCurrency('LTC')
|
||||
const coinRec = coinUtils.getCryptoCurrency('LTC')
|
||||
|
||||
function setup (dataDir) {
|
||||
common.firewall([coinRec.defaultPort])
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const path = require('path')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ const logger = common.logger
|
|||
function setup (dataDir) {
|
||||
es('sudo apt-get update')
|
||||
es('sudo apt-get install libgomp1 -y')
|
||||
const coinRec = utils.getCryptoCurrency('ZEC')
|
||||
const coinRec = coinUtils.getCryptoCurrency('ZEC')
|
||||
|
||||
common.firewall([coinRec.defaultPort])
|
||||
logger.info('Fetching Zcash proofs, will take a while...')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const BN = require('./bn')
|
||||
const configManager = require('./new-config-manager')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
function truncateCrypto (cryptoAtoms, cryptoCode) {
|
||||
const DECIMAL_PLACES = 3
|
||||
|
|
@ -20,7 +20,7 @@ function fiatToCrypto (tx, rec, deviceId, config) {
|
|||
const tickerRate = BN(tx.rawTickerPrice)
|
||||
const discount = getDiscountRate(tx.discount, commissions[tx.direction])
|
||||
const rate = tickerRate.mul(discount).round(5)
|
||||
const unitScale = utils.getCryptoCurrency(tx.cryptoCode).unitScale
|
||||
const unitScale = coinUtils.getCryptoCurrency(tx.cryptoCode).unitScale
|
||||
const unitScaleFactor = BN(10).pow(unitScale)
|
||||
|
||||
return truncateCrypto(BN(usableFiat).div(rate.div(unitScaleFactor)), tx.cryptoCode)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const ALL_ACCOUNTS = [
|
|||
{ code: 'bitcoind', display: 'bitcoind', class: WALLET, cryptos: [BTC] },
|
||||
{ code: 'no-layer2', display: 'No Layer 2', class: LAYER_2, cryptos: ALL_CRYPTOS },
|
||||
{ code: 'infura', display: 'Infura', class: WALLET, cryptos: [ETH, USDT] },
|
||||
{ code: 'geth', display: 'geth (DEPRECATED)', class: WALLET, cryptos: [ETH], deprecated: true },
|
||||
{ code: 'geth', display: 'geth (DEPRECATED)', class: WALLET, cryptos: [ETH, USDT], deprecated: true },
|
||||
{ code: 'zcashd', display: 'zcashd', class: WALLET, cryptos: [ZEC] },
|
||||
{ code: 'litecoind', display: 'litecoind', class: WALLET, cryptos: [LTC] },
|
||||
{ code: 'dashd', display: 'dashd', class: WALLET, cryptos: [DASH] },
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ const settingsLoader = require('../../new-settings-loader')
|
|||
const configManager = require('../../new-config-manager')
|
||||
const wallet = require('../../wallet')
|
||||
const ticker = require('../../ticker')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
function computeCrypto (cryptoCode, _balance) {
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
return BN(_balance).shift(-unitScale).round(5)
|
||||
}
|
||||
|
||||
function computeFiat (rate, cryptoCode, _balance) {
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
return BN(_balance).shift(-unitScale).mul(rate).round(5)
|
||||
|
|
@ -35,7 +35,7 @@ function getSingleCoinFunding (settings, fiatCode, cryptoCode) {
|
|||
const pending = fundingRec.fundingPendingBalance
|
||||
const fiatPending = computeFiat(rate, cryptoCode, pending)
|
||||
const fundingAddress = fundingRec.fundingAddress
|
||||
const fundingAddressUrl = utils.buildUrl(cryptoCode, fundingAddress)
|
||||
const fundingAddressUrl = coinUtils.buildUrl(cryptoCode, fundingAddress)
|
||||
|
||||
return {
|
||||
cryptoCode,
|
||||
|
|
@ -58,7 +58,7 @@ function getFunding () {
|
|||
const cryptoCodes = configManager.getAllCryptoCurrencies(settings.config)
|
||||
const fiatCode = configManager.getGlobalLocale(settings.config).fiatCurrency
|
||||
const pareCoins = c => _.includes(c.cryptoCode, cryptoCodes)
|
||||
const cryptoCurrencies = utils.cryptoCurrencies()
|
||||
const cryptoCurrencies = coinUtils.cryptoCurrencies()
|
||||
const cryptoDisplays = _.filter(pareCoins, cryptoCurrencies)
|
||||
|
||||
const promises = cryptoDisplays.map(it => getSingleCoinFunding(settings, fiatCode, it.cryptoCode))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const _ = require('lodash/fp')
|
||||
const crypto = require('crypto')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const numeral = require('numeral')
|
||||
const prettyMs = require('pretty-ms')
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ function sendNoAlerts (plugins, smsEnabled, emailEnabled) {
|
|||
const buildTransactionMessage = (tx, rec, highValueTx, machineName, customer) => {
|
||||
const isCashOut = tx.direction === 'cashOut'
|
||||
const direction = isCashOut ? 'Cash Out' : 'Cash In'
|
||||
const crypto = `${utils.toUnit(tx.cryptoAtoms, tx.cryptoCode)} ${
|
||||
const crypto = `${coinUtils.toUnit(tx.cryptoAtoms, tx.cryptoCode)} ${
|
||||
tx.cryptoCode
|
||||
}`
|
||||
const fiat = `${tx.fiat} ${tx.fiatCode}`
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const { cassetteMaxCapacity } = require('./constants')
|
|||
|
||||
const notifier = require('./notifier')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const mapValuesWithKey = _.mapValues.convert({
|
||||
cap: false
|
||||
|
|
@ -204,7 +204,7 @@ function plugins (settings, deviceId) {
|
|||
const cashInFee = BN(commissions.fixedFee)
|
||||
const cashInCommission = BN(commissions.cashIn)
|
||||
const cashOutCommission = _.isNumber(commissions.cashOut) ? BN(commissions.cashOut) : null
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
|
||||
return {
|
||||
cryptoCode,
|
||||
|
|
@ -335,7 +335,7 @@ function plugins (settings, deviceId) {
|
|||
|
||||
const lowBalanceMargin = BN(1.03)
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
const shiftedRate = rate.shift(-unitScale)
|
||||
const fiatTransferBalance = balance.mul(shiftedRate).div(lowBalanceMargin)
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
const PAIRS = {
|
||||
BTC: {
|
||||
USD: 'XXBTZUSD',
|
||||
EUR: 'XXBTZEUR'
|
||||
},
|
||||
ETH: {
|
||||
USD: 'XETHZUSD',
|
||||
EUR: 'XETHZEUR'
|
||||
},
|
||||
ZEC: {
|
||||
USD: 'XZECZUSD',
|
||||
EUR: 'XZECZEUR'
|
||||
},
|
||||
LTC: {
|
||||
USD: 'XLTCZUSD',
|
||||
EUR: 'XLTCZEUR'
|
||||
},
|
||||
DASH: {
|
||||
USD: 'DASHUSD',
|
||||
EUR: 'DASHEUR'
|
||||
},
|
||||
BCH: {
|
||||
USD: 'BCHUSD',
|
||||
EUR: 'BCHEUR'
|
||||
},
|
||||
USDT: {
|
||||
USD: 'USDTZUSD',
|
||||
EUR: 'USDTEUR'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {PAIRS}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +0,0 @@
|
|||
const USDT = require('./abi/usdt.json')
|
||||
|
||||
module.exports = { USDT }
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
const common = require('../../common/bitstamp')
|
||||
const { utils } = require('lamassu-coins')
|
||||
|
||||
function buy (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade('buy', account, cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
function sell (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade('sell', account, cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
function handleErrors (data) {
|
||||
if (!data.reason || !data.reason.__all__) return data
|
||||
|
||||
const err = new Error(data.reason.__all__[0])
|
||||
|
||||
if (data.reason.__all__[0].indexOf('Minimum order size is') === 0) {
|
||||
err.name = 'orderTooSmall'
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
function trade (type, account, cryptoAtoms, _fiatCode, cryptoCode) {
|
||||
const fiatCode = _fiatCode === 'USD' ? 'USD' : 'EUR'
|
||||
|
||||
try {
|
||||
const market = common.buildMarket(fiatCode, cryptoCode)
|
||||
const options = {amount: utils.toUnit(cryptoAtoms, cryptoCode).toFixed(8)}
|
||||
|
||||
return common.authRequest(account, '/' + type + '/market/' + market, options)
|
||||
.catch(e => {
|
||||
if (e.response) handleErrors(e.response.data)
|
||||
throw e
|
||||
})
|
||||
.then(handleErrors)
|
||||
} catch (e) {
|
||||
return Promise.reject(e)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buy,
|
||||
sell
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
const common = require('../../common/itbit')
|
||||
const { utils } = require('lamassu-coins')
|
||||
|
||||
exports.buy = function (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade('buy', account, cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
exports.sell = function (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade('sell', account, cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
function trade (type, account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
try {
|
||||
const instrument = common.buildMarket(fiatCode, cryptoCode)
|
||||
const cryptoAmount = utils.toUnit(cryptoAtoms, cryptoCode)
|
||||
|
||||
return calculatePrice(type, instrument, cryptoAmount)
|
||||
.then(price => {
|
||||
const args = {
|
||||
side: type,
|
||||
type: 'limit',
|
||||
currency: cryptoCode,
|
||||
amount: cryptoAmount.toFixed(4),
|
||||
price: price.toFixed(2),
|
||||
instrument: instrument
|
||||
}
|
||||
return common.authRequest(account, 'POST', '/wallets/' + account.walletId + '/orders', args)
|
||||
})
|
||||
} catch (e) {
|
||||
return Promise.reject(e)
|
||||
}
|
||||
}
|
||||
|
||||
function calculatePrice (type, tickerSymbol, amount) {
|
||||
return common.request('GET', '/markets/' + tickerSymbol + '/order_book')
|
||||
.then(orderBook => {
|
||||
const book = type == 'buy' ? 'asks' : 'bids'
|
||||
let collected = 0.0
|
||||
for (const entry of orderBook[book]) {
|
||||
collected += parseFloat(entry[1])
|
||||
if (collected >= amount) return parseFloat(entry[0])
|
||||
}
|
||||
throw new Error('Insufficient market depth')
|
||||
})
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
// Note: Using DeX3/npm-kraken-api to adjust timeout time
|
||||
const Kraken = require('kraken-api')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const common = require('../../common/kraken')
|
||||
const { utils } = require('lamassu-coins')
|
||||
|
||||
var PAIRS = common.PAIRS
|
||||
|
||||
module.exports = {buy, sell}
|
||||
|
||||
function buy (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade(account, 'buy', cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
function sell (account, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return trade(account, 'sell', cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
|
||||
function trade (account, type, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
const kraken = new Kraken(account.apiKey, account.privateKey, {timeout: 30000})
|
||||
const amount = utils.toUnit(cryptoAtoms, cryptoCode)
|
||||
const amountStr = amount.toFixed(6)
|
||||
|
||||
const pair = _.includes(fiatCode, ['USD', 'EUR'])
|
||||
? PAIRS[cryptoCode][fiatCode]
|
||||
: PAIRS[cryptoCode]['EUR']
|
||||
|
||||
var orderInfo = {
|
||||
pair,
|
||||
type,
|
||||
ordertype: 'market',
|
||||
volume: amountStr,
|
||||
expiretm: '+60'
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
kraken.api('AddOrder', orderInfo, (error, response) => {
|
||||
if (error) return reject(error)
|
||||
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
282
lib/plugins/tokens/erc20.abi.json
Normal file
282
lib/plugins/tokens/erc20.abi.json
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
[
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
|
||||
],
|
||||
"name":"name",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"",
|
||||
"type":"string"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":false,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_spender",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"name":"approve",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"success",
|
||||
"type":"bool"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
|
||||
],
|
||||
"name":"totalSupply",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":false,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_from",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_to",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"name":"transferFrom",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"success",
|
||||
"type":"bool"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
|
||||
],
|
||||
"name":"decimals",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
|
||||
],
|
||||
"name":"version",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"",
|
||||
"type":"string"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_owner",
|
||||
"type":"address"
|
||||
}
|
||||
],
|
||||
"name":"balanceOf",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"balance",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
|
||||
],
|
||||
"name":"symbol",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"",
|
||||
"type":"string"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":false,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_to",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"name":"transfer",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"success",
|
||||
"type":"bool"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":false,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_spender",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
},
|
||||
{
|
||||
"name":"_extraData",
|
||||
"type":"bytes"
|
||||
}
|
||||
],
|
||||
"name":"approveAndCall",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"success",
|
||||
"type":"bool"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"constant":true,
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_owner",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"name":"_spender",
|
||||
"type":"address"
|
||||
}
|
||||
],
|
||||
"name":"allowance",
|
||||
"outputs":[
|
||||
{
|
||||
"name":"remaining",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"payable":false,
|
||||
"type":"function"
|
||||
},
|
||||
{
|
||||
"inputs":[
|
||||
{
|
||||
"name":"_initialAmount",
|
||||
"type":"uint256"
|
||||
},
|
||||
{
|
||||
"name":"_tokenName",
|
||||
"type":"string"
|
||||
},
|
||||
{
|
||||
"name":"_decimalUnits",
|
||||
"type":"uint8"
|
||||
},
|
||||
{
|
||||
"name":"_tokenSymbol",
|
||||
"type":"string"
|
||||
}
|
||||
],
|
||||
"type":"constructor"
|
||||
},
|
||||
{
|
||||
"payable":false,
|
||||
"type":"fallback"
|
||||
},
|
||||
{
|
||||
"anonymous":false,
|
||||
"inputs":[
|
||||
{
|
||||
"indexed":true,
|
||||
"name":"_from",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"indexed":true,
|
||||
"name":"_to",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"indexed":false,
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"name":"Transfer",
|
||||
"type":"event"
|
||||
},
|
||||
{
|
||||
"anonymous":false,
|
||||
"inputs":[
|
||||
{
|
||||
"indexed":true,
|
||||
"name":"_owner",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"indexed":true,
|
||||
"name":"_spender",
|
||||
"type":"address"
|
||||
},
|
||||
{
|
||||
"indexed":false,
|
||||
"name":"_value",
|
||||
"type":"uint256"
|
||||
}
|
||||
],
|
||||
"name":"Approval",
|
||||
"type":"event"
|
||||
}
|
||||
]
|
||||
3
lib/plugins/tokens/index.js
Normal file
3
lib/plugins/tokens/index.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
const ERC20 = require('./erc20.abi')
|
||||
|
||||
module.exports = { ERC20 }
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
const _ = require('lodash/fp')
|
||||
const jsonRpc = require('../../common/json-rpc')
|
||||
|
||||
const blockchainUtils = require('../../../coin-utils')
|
||||
const blockchainUtils = require('../../../blockchain-utils')
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('BCH')
|
||||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
||||
const configPath = coinUtils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
function rpcConfig () {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
const _ = require('lodash/fp')
|
||||
const jsonRpc = require('../../common/json-rpc')
|
||||
|
||||
const blockchainUtils = require('../../../coin-utils')
|
||||
const blockchainUtils = require('../../../blockchain-utils')
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('BTC')
|
||||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
||||
const configPath = coinUtils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
function rpcConfig () {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
const _ = require('lodash/fp')
|
||||
const jsonRpc = require('../../common/json-rpc')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const blockchainUtils = require('../../../coin-utils')
|
||||
const blockchainUtils = require('../../../blockchain-utils')
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('DASH')
|
||||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
||||
const configPath = coinUtils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
function rpcConfig () {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const util = require('ethereumjs-util')
|
|||
const coins = require('lamassu-coins')
|
||||
const pify = require('pify')
|
||||
const BN = require('../../../bn')
|
||||
const erc20ABIs = require('../../erc20')
|
||||
const ABI = require('../../tokens')
|
||||
|
||||
const NAME = 'geth'
|
||||
exports.SUPPORTED_MODULES = ['wallet']
|
||||
|
|
@ -84,7 +84,7 @@ const confirmedBalance = (address, cryptoCode) => _balance(false, address, crypt
|
|||
|
||||
function _balance (includePending, address, cryptoCode) {
|
||||
if (coins.utils.getCryptoCurrency(cryptoCode).type === 'erc-20') {
|
||||
const contract = web3.eth.contract(erc20ABIs[cryptoCode]).at(coins.utils.getErc20Token(cryptoCode).contractAddress)
|
||||
const contract = web3.eth.contract(ABI.ERC20).at(coins.utils.getErc20Token(cryptoCode).contractAddress)
|
||||
return contract.balanceOf(address.toLowerCase())
|
||||
}
|
||||
const block = includePending ? 'pending' : undefined
|
||||
|
|
@ -98,7 +98,7 @@ function generateTx (toAddress, wallet, amount, includesFee, cryptoCode) {
|
|||
}
|
||||
|
||||
function generateContractTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
||||
const contract = web3.eth.contract(erc20ABIs[cryptoCode]).at(coins.utils.getErc20Token(cryptoCode).contractAddress)
|
||||
const contract = web3.eth.contract(ABI.ERC20).at(coins.utils.getErc20Token(cryptoCode).contractAddress)
|
||||
|
||||
const fromAddress = '0x' + wallet.getAddress().toString('hex')
|
||||
const toAddress = _toAddress.toLowerCase()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const base = require('./base')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const cryptoRec = utils.getCryptoCurrency('ETH')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('ETH')
|
||||
const defaultPort = cryptoRec.defaultPort
|
||||
|
||||
base.connect(`http://localhost:${defaultPort}`)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
const _ = require('lodash/fp')
|
||||
const jsonRpc = require('../../common/json-rpc')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const blockchainUtils = require('../../../coin-utils')
|
||||
const blockchainUtils = require('../../../blockchain-utils')
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('LTC')
|
||||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
||||
const configPath = coinUtils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
function rpcConfig () {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ const lnd = require('lnd-async')
|
|||
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const options = require('../../../options')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('BTC')
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const NAME = 'FakeWallet'
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ const CONFIRM_TIME = AUTHORIZE_TIME + 120 * SECONDS
|
|||
let t0
|
||||
|
||||
function _balance (cryptoCode) {
|
||||
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const unitScale = cryptoRec.unitScale
|
||||
return BN(10).shift(unitScale).round()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ const _ = require('lodash/fp')
|
|||
const pRetry = require('p-retry')
|
||||
const jsonRpc = require('../../common/json-rpc')
|
||||
|
||||
const { utils } = require('lamassu-coins')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const blockchainUtils = require('../../../coin-utils')
|
||||
const blockchainUtils = require('../../../blockchain-utils')
|
||||
const BN = require('../../../bn')
|
||||
const E = require('../../../error')
|
||||
|
||||
const cryptoRec = utils.getCryptoCurrency('ZEC')
|
||||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('ZEC')
|
||||
const configPath = coinUtils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
function rpcConfig () {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { makeStyles, Box } from '@material-ui/core'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import { utils } from 'lamassu-coins'
|
||||
import { utils as coinUtils } from 'lamassu-coins'
|
||||
import * as R from 'ramda'
|
||||
import React from 'react'
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ const TransactionsList = ({ customer, data, loading, locale }) => {
|
|||
textAlign: 'right',
|
||||
view: it => (
|
||||
<>
|
||||
{`${utils
|
||||
{`${coinUtils
|
||||
.toUnit(new BigNumber(it.cryptoAtoms), it.cryptoCode)
|
||||
.toFormat(5)} `}
|
||||
<Label2 inline>{it.cryptoCode}</Label2>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles'
|
|||
import BigNumber from 'bignumber.js'
|
||||
import classnames from 'classnames'
|
||||
import gql from 'graphql-tag'
|
||||
import { utils } from 'lamassu-coins'
|
||||
import { utils as coinUtils } from 'lamassu-coins'
|
||||
import moment from 'moment'
|
||||
import QRCode from 'qrcode.react'
|
||||
import * as R from 'ramda'
|
||||
|
|
@ -52,7 +52,7 @@ const GET_FUNDING = gql`
|
|||
`
|
||||
|
||||
const formatAddress = (cryptoCode = '', address = '') =>
|
||||
utils.formatCryptoAddress(cryptoCode, address).replace(/(.{4})/g, '$1 ')
|
||||
coinUtils.formatCryptoAddress(cryptoCode, address).replace(/(.{4})/g, '$1 ')
|
||||
const sumReducer = (acc, value) => acc.plus(value)
|
||||
const formatNumber = it => new BigNumber(it).toFormat(2)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { useLazyQuery } from '@apollo/react-hooks'
|
|||
import { makeStyles } from '@material-ui/core'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import gql from 'graphql-tag'
|
||||
import { utils } from 'lamassu-coins'
|
||||
import { utils as coinUtils } from 'lamassu-coins'
|
||||
import moment from 'moment'
|
||||
import * as R from 'ramda'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
|
@ -118,13 +118,13 @@ const Transactions = ({ id }) => {
|
|||
textAlign: 'right',
|
||||
size: 'sm',
|
||||
view: it =>
|
||||
`${utils
|
||||
`${coinUtils
|
||||
.toUnit(new BigNumber(it.cryptoAtoms), it.cryptoCode)
|
||||
.toFormat(5)} ${it.cryptoCode}`
|
||||
},
|
||||
{
|
||||
header: 'Address',
|
||||
view: it => utils.formatCryptoAddress(it.cryptoCode, it.toAddress),
|
||||
view: it => coinUtils.formatCryptoAddress(it.cryptoCode, it.toAddress),
|
||||
className: classes.overflowTd,
|
||||
size: 'sm',
|
||||
textAlign: 'left',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import BigNumber from 'bignumber.js'
|
|||
import FileSaver from 'file-saver'
|
||||
import gql from 'graphql-tag'
|
||||
import JSZip from 'jszip'
|
||||
import { utils } from 'lamassu-coins'
|
||||
import { utils as coinUtils } from 'lamassu-coins'
|
||||
import moment from 'moment'
|
||||
import * as R from 'ramda'
|
||||
import React, { memo } from 'react'
|
||||
|
|
@ -53,7 +53,7 @@ const TX_SUMMARY = gql`
|
|||
`
|
||||
|
||||
const formatAddress = (cryptoCode = '', address = '') =>
|
||||
utils.formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ')
|
||||
coinUtils.formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ')
|
||||
|
||||
const Label = ({ children }) => {
|
||||
const classes = useStyles()
|
||||
|
|
@ -70,7 +70,7 @@ const DetailsRow = ({ it: tx }) => {
|
|||
})
|
||||
|
||||
const fiat = Number.parseFloat(tx.fiat)
|
||||
const crypto = utils.toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode)
|
||||
const crypto = coinUtils.toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode)
|
||||
const commissionPercentage = Number.parseFloat(tx.commissionPercentage, 2)
|
||||
const commission = Number(fiat * commissionPercentage).toFixed(2)
|
||||
const discount = tx.discount ? `-${tx.discount}%` : null
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { useQuery } from '@apollo/react-hooks'
|
|||
import { makeStyles } from '@material-ui/core'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import gql from 'graphql-tag'
|
||||
import { utils } from 'lamassu-coins'
|
||||
import { utils as coinUtils } from 'lamassu-coins'
|
||||
import * as R from 'ramda'
|
||||
import React from 'react'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
|
|
@ -139,13 +139,13 @@ const Transactions = () => {
|
|||
textAlign: 'right',
|
||||
size: 'sm',
|
||||
view: it =>
|
||||
`${utils
|
||||
`${coinUtils
|
||||
.toUnit(new BigNumber(it.cryptoAtoms), it.cryptoCode)
|
||||
.toFormat(5)} ${it.cryptoCode}`
|
||||
},
|
||||
{
|
||||
header: 'Address',
|
||||
view: it => utils.formatCryptoAddress(it.cryptoCode, it.toAddress),
|
||||
view: it => coinUtils.formatCryptoAddress(it.cryptoCode, it.toAddress),
|
||||
className: classes.overflowTd,
|
||||
size: 'sm',
|
||||
width: 140
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue