From 8e099e3283e9ea3270c69c121c88ade5de30f1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 10 Jun 2021 01:43:22 +0100 Subject: [PATCH] feat: change to generic ERC-20 ABI json file fix: coinUtils rename import --- lib/admin/funding.js | 12 +- lib/{coin-utils.js => blockchain-utils.js} | 0 lib/blockchain/bitcoin.js | 4 +- lib/blockchain/bitcoincash.js | 4 +- lib/blockchain/dash.js | 4 +- lib/blockchain/ethereum.js | 4 +- lib/blockchain/install.js | 12 +- lib/blockchain/litecoin.js | 4 +- lib/blockchain/zcash.js | 4 +- lib/commission-math.js | 4 +- lib/new-admin/config/accounts.js | 2 +- lib/new-admin/services/funding.js | 10 +- lib/notifier/utils.js | 4 +- lib/plugins.js | 6 +- lib/plugins/common/kraken.js | 32 -- lib/plugins/erc20/abi/usdt.json | 1 - lib/plugins/erc20/index.js | 3 - lib/plugins/exchange/bitstamp/bitstamp.js | 45 --- lib/plugins/exchange/itbit/itbit.js | 45 --- lib/plugins/exchange/kraken/kraken.js | 44 --- lib/plugins/tokens/erc20.abi.json | 282 ++++++++++++++++++ lib/plugins/tokens/index.js | 3 + .../wallet/bitcoincashd/bitcoincashd.js | 8 +- lib/plugins/wallet/bitcoind/bitcoind.js | 8 +- lib/plugins/wallet/dashd/dashd.js | 8 +- lib/plugins/wallet/geth/base.js | 6 +- lib/plugins/wallet/geth/geth.js | 4 +- lib/plugins/wallet/litecoind/litecoind.js | 8 +- lib/plugins/wallet/lnd/lnd.js | 4 +- lib/plugins/wallet/mock-wallet/mock-wallet.js | 4 +- lib/plugins/wallet/zcashd/zcashd.js | 8 +- .../Customers/components/TransactionsList.js | 4 +- new-lamassu-admin/src/pages/Funding.js | 4 +- .../Transactions/Transactions.js | 6 +- .../src/pages/Transactions/DetailsCard.js | 6 +- .../src/pages/Transactions/Transactions.js | 6 +- 36 files changed, 364 insertions(+), 249 deletions(-) rename lib/{coin-utils.js => blockchain-utils.js} (100%) delete mode 100644 lib/plugins/common/kraken.js delete mode 100644 lib/plugins/erc20/abi/usdt.json delete mode 100644 lib/plugins/erc20/index.js delete mode 100644 lib/plugins/exchange/bitstamp/bitstamp.js delete mode 100644 lib/plugins/exchange/itbit/itbit.js delete mode 100644 lib/plugins/exchange/kraken/kraken.js create mode 100644 lib/plugins/tokens/erc20.abi.json create mode 100644 lib/plugins/tokens/index.js diff --git a/lib/admin/funding.js b/lib/admin/funding.js index 12a9f9bd..5beeea25 100644 --- a/lib/admin/funding.js +++ b/lib/admin/funding.js @@ -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, diff --git a/lib/coin-utils.js b/lib/blockchain-utils.js similarity index 100% rename from lib/coin-utils.js rename to lib/blockchain-utils.js diff --git a/lib/blockchain/bitcoin.js b/lib/blockchain/bitcoin.js index f4a966b5..88e38988 100644 --- a/lib/blockchain/bitcoin.js +++ b/lib/blockchain/bitcoin.js @@ -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]) diff --git a/lib/blockchain/bitcoincash.js b/lib/blockchain/bitcoincash.js index 98cba208..7b366c36 100644 --- a/lib/blockchain/bitcoincash.js +++ b/lib/blockchain/bitcoincash.js @@ -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]) diff --git a/lib/blockchain/dash.js b/lib/blockchain/dash.js index 5b8bd696..fda8a523 100644 --- a/lib/blockchain/dash.js +++ b/lib/blockchain/dash.js @@ -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]) diff --git a/lib/blockchain/ethereum.js b/lib/blockchain/ethereum.js index b4190620..1e8bf2fc 100644 --- a/lib/blockchain/ethereum.js +++ b/lib/blockchain/ethereum.js @@ -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) diff --git a/lib/blockchain/install.js b/lib/blockchain/install.js index 3dd0b44d..3671bd34 100644 --- a/lib/blockchain/install.js +++ b/lib/blockchain/install.js @@ -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() diff --git a/lib/blockchain/litecoin.js b/lib/blockchain/litecoin.js index d0fc9705..48e24e2d 100644 --- a/lib/blockchain/litecoin.js +++ b/lib/blockchain/litecoin.js @@ -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]) diff --git a/lib/blockchain/zcash.js b/lib/blockchain/zcash.js index f148e4ef..0032609a 100644 --- a/lib/blockchain/zcash.js +++ b/lib/blockchain/zcash.js @@ -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...') diff --git a/lib/commission-math.js b/lib/commission-math.js index fd0cd91f..d228f3d8 100644 --- a/lib/commission-math.js +++ b/lib/commission-math.js @@ -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) diff --git a/lib/new-admin/config/accounts.js b/lib/new-admin/config/accounts.js index 8feda474..7fbd76dd 100644 --- a/lib/new-admin/config/accounts.js +++ b/lib/new-admin/config/accounts.js @@ -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] }, diff --git a/lib/new-admin/services/funding.js b/lib/new-admin/services/funding.js index 9aaecf44..25e5f606 100644 --- a/lib/new-admin/services/funding.js +++ b/lib/new-admin/services/funding.js @@ -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)) diff --git a/lib/notifier/utils.js b/lib/notifier/utils.js index 374473b7..4f71c5ec 100644 --- a/lib/notifier/utils.js +++ b/lib/notifier/utils.js @@ -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}` diff --git a/lib/plugins.js b/lib/plugins.js index 3d038710..e6ce8ef3 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -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) diff --git a/lib/plugins/common/kraken.js b/lib/plugins/common/kraken.js deleted file mode 100644 index f84648ad..00000000 --- a/lib/plugins/common/kraken.js +++ /dev/null @@ -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} diff --git a/lib/plugins/erc20/abi/usdt.json b/lib/plugins/erc20/abi/usdt.json deleted file mode 100644 index 6f8bda21..00000000 --- a/lib/plugins/erc20/abi/usdt.json +++ /dev/null @@ -1 +0,0 @@ -[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_upgradedAddress","type":"address"}],"name":"deprecate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"deprecated","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_evilUser","type":"address"}],"name":"addBlackList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"upgradedAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maximumFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_maker","type":"address"}],"name":"getBlackListStatus","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newBasisPoints","type":"uint256"},{"name":"newMaxFee","type":"uint256"}],"name":"setParams","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"issue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"redeem","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"basisPointsRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isBlackListed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_clearedUser","type":"address"}],"name":"removeBlackList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_blackListedUser","type":"address"}],"name":"destroyBlackFunds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_initialSupply","type":"uint256"},{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Issue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newAddress","type":"address"}],"name":"Deprecate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"feeBasisPoints","type":"uint256"},{"indexed":false,"name":"maxFee","type":"uint256"}],"name":"Params","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_blackListedUser","type":"address"},{"indexed":false,"name":"_balance","type":"uint256"}],"name":"DestroyedBlackFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_user","type":"address"}],"name":"AddedBlackList","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_user","type":"address"}],"name":"RemovedBlackList","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"},{"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":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"}] diff --git a/lib/plugins/erc20/index.js b/lib/plugins/erc20/index.js deleted file mode 100644 index a06320c3..00000000 --- a/lib/plugins/erc20/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const USDT = require('./abi/usdt.json') - -module.exports = { USDT } diff --git a/lib/plugins/exchange/bitstamp/bitstamp.js b/lib/plugins/exchange/bitstamp/bitstamp.js deleted file mode 100644 index ebb626ee..00000000 --- a/lib/plugins/exchange/bitstamp/bitstamp.js +++ /dev/null @@ -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 -} diff --git a/lib/plugins/exchange/itbit/itbit.js b/lib/plugins/exchange/itbit/itbit.js deleted file mode 100644 index 80592d13..00000000 --- a/lib/plugins/exchange/itbit/itbit.js +++ /dev/null @@ -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') - }) -} diff --git a/lib/plugins/exchange/kraken/kraken.js b/lib/plugins/exchange/kraken/kraken.js deleted file mode 100644 index ca3c4872..00000000 --- a/lib/plugins/exchange/kraken/kraken.js +++ /dev/null @@ -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() - }) - }) -} diff --git a/lib/plugins/tokens/erc20.abi.json b/lib/plugins/tokens/erc20.abi.json new file mode 100644 index 00000000..b66cb33f --- /dev/null +++ b/lib/plugins/tokens/erc20.abi.json @@ -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" + } +] \ No newline at end of file diff --git a/lib/plugins/tokens/index.js b/lib/plugins/tokens/index.js new file mode 100644 index 00000000..e58c02d6 --- /dev/null +++ b/lib/plugins/tokens/index.js @@ -0,0 +1,3 @@ +const ERC20 = require('./erc20.abi') + +module.exports = { ERC20 } diff --git a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js index d634692c..c666e4e0 100644 --- a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js +++ b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js @@ -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 () { diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index e40a0c5e..0c04f52c 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -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 () { diff --git a/lib/plugins/wallet/dashd/dashd.js b/lib/plugins/wallet/dashd/dashd.js index 582dd830..abc7288c 100644 --- a/lib/plugins/wallet/dashd/dashd.js +++ b/lib/plugins/wallet/dashd/dashd.js @@ -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 () { diff --git a/lib/plugins/wallet/geth/base.js b/lib/plugins/wallet/geth/base.js index be3164c8..93fd43ce 100644 --- a/lib/plugins/wallet/geth/base.js +++ b/lib/plugins/wallet/geth/base.js @@ -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() diff --git a/lib/plugins/wallet/geth/geth.js b/lib/plugins/wallet/geth/geth.js index 63e0fd95..40a44726 100644 --- a/lib/plugins/wallet/geth/geth.js +++ b/lib/plugins/wallet/geth/geth.js @@ -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}`) diff --git a/lib/plugins/wallet/litecoind/litecoind.js b/lib/plugins/wallet/litecoind/litecoind.js index 2ad98528..aa5a5d7c 100644 --- a/lib/plugins/wallet/litecoind/litecoind.js +++ b/lib/plugins/wallet/litecoind/litecoind.js @@ -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 () { diff --git a/lib/plugins/wallet/lnd/lnd.js b/lib/plugins/wallet/lnd/lnd.js index 5a5daa35..a3fcb821 100644 --- a/lib/plugins/wallet/lnd/lnd.js +++ b/lib/plugins/wallet/lnd/lnd.js @@ -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 = { diff --git a/lib/plugins/wallet/mock-wallet/mock-wallet.js b/lib/plugins/wallet/mock-wallet/mock-wallet.js index 6ff6c569..c7a34e5b 100644 --- a/lib/plugins/wallet/mock-wallet/mock-wallet.js +++ b/lib/plugins/wallet/mock-wallet/mock-wallet.js @@ -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() } diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 9ae08ec5..4c40e73a 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -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 () { diff --git a/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js b/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js index 0306d981..67690b3a 100644 --- a/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js +++ b/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js @@ -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)} `} {it.cryptoCode} diff --git a/new-lamassu-admin/src/pages/Funding.js b/new-lamassu-admin/src/pages/Funding.js index 420db7aa..4057232c 100644 --- a/new-lamassu-admin/src/pages/Funding.js +++ b/new-lamassu-admin/src/pages/Funding.js @@ -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) diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js index cf5597ba..aeeae9b7 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js @@ -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', diff --git a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js index 7ef372c2..7b475c39 100644 --- a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js +++ b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js @@ -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 diff --git a/new-lamassu-admin/src/pages/Transactions/Transactions.js b/new-lamassu-admin/src/pages/Transactions/Transactions.js index 7bbba3b6..0f911ca1 100644 --- a/new-lamassu-admin/src/pages/Transactions/Transactions.js +++ b/new-lamassu-admin/src/pages/Transactions/Transactions.js @@ -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