diff --git a/lib/admin/schemas/gajoy.json b/lib/admin/schemas/gajoy.json new file mode 100644 index 00000000..5076cc8a --- /dev/null +++ b/lib/admin/schemas/gajoy.json @@ -0,0 +1,23 @@ +{ + "code": "galoy", + "display": "Galoy", + "fields": [ + { + "code": "apiKey", + "display": "API Key", + "fieldType": "string", + "secret": true, + "required": true, + "value": "" + }, + { + "code": "walletId", + "display": "Wallet ID", + "fieldType": "password", + "secret": true, + "required": true, + "value": "" + } + ] + } + \ No newline at end of file diff --git a/lib/new-settings-loader.js b/lib/new-settings-loader.js index 62b9d3fb..1831b9cd 100644 --- a/lib/new-settings-loader.js +++ b/lib/new-settings-loader.js @@ -25,7 +25,8 @@ const SECRET_FIELDS = [ 'binance.privateKey', 'twilio.authToken', 'telnyx.apiKey', - 'vonage.apiSecret' + 'vonage.apiSecret', + 'galoy.walletId' ] /* diff --git a/lib/plugins/common/ccxt.js b/lib/plugins/common/ccxt.js index 6b731d85..c4c54245 100644 --- a/lib/plugins/common/ccxt.js +++ b/lib/plugins/common/ccxt.js @@ -1,5 +1,6 @@ const { COINS } = require('@lamassu/coins') const _ = require('lodash/fp') +const { utils: coinUtils } = require('@lamassu/coins') const kraken = require('../exchange/kraken') const bitstamp = require('../exchange/bitstamp') @@ -27,15 +28,16 @@ const ALL = { } function buildMarket (fiatCode, cryptoCode, serviceName) { - if (!_.includes(cryptoCode, ALL[serviceName].CRYPTO)) { - throw new Error('Unsupported crypto: ' + cryptoCode) + const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode) + if (!_.includes(externalCryptoCode, ALL[serviceName].CRYPTO)) { + throw new Error('Unsupported crypto: ' + externalCryptoCode) } const fiatSupported = ALL[serviceName].FIAT if (fiatSupported !== 'ALL_CURRENCIES' && !_.includes(fiatCode, fiatSupported)) { logger.info('Building a market for an unsupported fiat. Defaulting to EUR market') return cryptoCode + '/' + 'EUR' } - return cryptoCode + '/' + fiatCode + return externalCryptoCode + '/' + fiatCode } function verifyFiatSupport (fiatCode, serviceName) { diff --git a/new-lamassu-admin/src/pages/Services/schemas/galoy.js b/new-lamassu-admin/src/pages/Services/schemas/galoy.js new file mode 100644 index 00000000..ac6fa6b0 --- /dev/null +++ b/new-lamassu-admin/src/pages/Services/schemas/galoy.js @@ -0,0 +1,36 @@ +import * as Yup from 'yup' + +import SecretInputFormik from 'src/components/inputs/formik/SecretInput' +import TextInputFormik from 'src/components/inputs/formik/TextInput' + +import { secretTest } from './helper' + +export default { + code: 'galoy', + name: 'Galoy', + title: 'Galoy (Wallet)', + elements: [ + { + code: 'apiKey', + display: 'API Key', + component: TextInputFormik, + face: true, + long: true + }, + { + code: 'walletId', + display: 'Wallet ID', + component: SecretInputFormik + } + ], + getValidationSchema: account => { + return Yup.object().shape({ + apiKey: Yup.string('The API key must be a string') + .max(100, 'The API key is too long') + .required('The API key is required'), + walletId: Yup.string('The wallet id must be a string') + .max(100, 'The wallet id is too long') + .test(secretTest(account?.walletId)) + }) + } +} diff --git a/new-lamassu-admin/src/pages/Services/schemas/index.js b/new-lamassu-admin/src/pages/Services/schemas/index.js index 3ff44631..050ccdd2 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/index.js +++ b/new-lamassu-admin/src/pages/Services/schemas/index.js @@ -5,6 +5,7 @@ import bitstamp from './bitstamp' import blockcypher from './blockcypher' import cex from './cex' import ciphertrace from './ciphertrace' +import galoy from './galoy' import infura from './infura' import itbit from './itbit' import kraken from './kraken' @@ -16,6 +17,7 @@ import vonage from './vonage' export default { [bitgo.code]: bitgo, + [galoy.code]: galoy, [bitstamp.code]: bitstamp, [blockcypher.code]: blockcypher, [infura.code]: infura, diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseExchange.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseExchange.js index 5c3bb08b..d7225778 100644 --- a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseExchange.js +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseExchange.js @@ -1,4 +1,5 @@ import { useQuery, useMutation } from '@apollo/react-hooks' +import { utils as coinUtils } from '@lamassu/coins' import { makeStyles } from '@material-ui/core' import gql from 'graphql-tag' import * as R from 'ramda' @@ -54,7 +55,7 @@ const ChooseExchange = ({ data: currentData, addData }) => { const accounts = data?.accounts ?? [] const accountsConfig = data?.accountsConfig ?? [] - const coin = currentData.coin + const coin = coinUtils.getExternalCryptoCode(currentData.coin) const exchanges = getItems(accountsConfig, accounts, 'exchange', coin) const submit = () => { diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseTicker.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseTicker.js index ca5e0955..8d320ea3 100644 --- a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseTicker.js +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseTicker.js @@ -1,4 +1,5 @@ import { useQuery } from '@apollo/react-hooks' +import { utils as coinUtils } from '@lamassu/coins' import { makeStyles } from '@material-ui/core' import gql from 'graphql-tag' import * as R from 'ramda' @@ -34,7 +35,7 @@ const ChooseTicker = ({ data: currentData, addData }) => { const accounts = data?.accounts ?? [] const accountsConfig = data?.accountsConfig ?? [] - const coin = currentData.coin + const coin = coinUtils.getExternalCryptoCode(currentData.coin) const tickers = getItems(accountsConfig, accounts, 'ticker', coin) const submit = () => { diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseWallet.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseWallet.js index 94f78241..2f376783 100644 --- a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseWallet.js +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ChooseWallet.js @@ -39,7 +39,8 @@ const SAVE_ACCOUNTS = gql` } ` -const isConfigurable = it => R.contains(it)(['infura', 'bitgo', 'trongrid']) +const isConfigurable = it => + R.contains(it)(['infura', 'bitgo', 'trongrid', 'galoy']) const isLocalHosted = it => R.contains(it)([ @@ -167,6 +168,19 @@ const ChooseWallet = ({ data: currentData, addData }) => { /> )} + {selected === 'galoy' && ( + <> +

Enter wallet information

+ + + )} ) }