feat: galoy account setup

This commit is contained in:
José Oliveira 2022-04-12 17:27:38 +01:00 committed by siiky
parent f870b9f563
commit 688ec0bcbc
8 changed files with 87 additions and 7 deletions

View file

@ -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": ""
}
]
}

View file

@ -25,7 +25,8 @@ const SECRET_FIELDS = [
'binance.privateKey', 'binance.privateKey',
'twilio.authToken', 'twilio.authToken',
'telnyx.apiKey', 'telnyx.apiKey',
'vonage.apiSecret' 'vonage.apiSecret',
'galoy.walletId'
] ]
/* /*

View file

@ -1,5 +1,6 @@
const { COINS } = require('@lamassu/coins') const { COINS } = require('@lamassu/coins')
const _ = require('lodash/fp') const _ = require('lodash/fp')
const { utils: coinUtils } = require('@lamassu/coins')
const kraken = require('../exchange/kraken') const kraken = require('../exchange/kraken')
const bitstamp = require('../exchange/bitstamp') const bitstamp = require('../exchange/bitstamp')
@ -27,15 +28,16 @@ const ALL = {
} }
function buildMarket (fiatCode, cryptoCode, serviceName) { function buildMarket (fiatCode, cryptoCode, serviceName) {
if (!_.includes(cryptoCode, ALL[serviceName].CRYPTO)) { const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
throw new Error('Unsupported crypto: ' + cryptoCode) if (!_.includes(externalCryptoCode, ALL[serviceName].CRYPTO)) {
throw new Error('Unsupported crypto: ' + externalCryptoCode)
} }
const fiatSupported = ALL[serviceName].FIAT const fiatSupported = ALL[serviceName].FIAT
if (fiatSupported !== 'ALL_CURRENCIES' && !_.includes(fiatCode, fiatSupported)) { if (fiatSupported !== 'ALL_CURRENCIES' && !_.includes(fiatCode, fiatSupported)) {
logger.info('Building a market for an unsupported fiat. Defaulting to EUR market') logger.info('Building a market for an unsupported fiat. Defaulting to EUR market')
return cryptoCode + '/' + 'EUR' return cryptoCode + '/' + 'EUR'
} }
return cryptoCode + '/' + fiatCode return externalCryptoCode + '/' + fiatCode
} }
function verifyFiatSupport (fiatCode, serviceName) { function verifyFiatSupport (fiatCode, serviceName) {

View file

@ -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))
})
}
}

View file

@ -5,6 +5,7 @@ import bitstamp from './bitstamp'
import blockcypher from './blockcypher' import blockcypher from './blockcypher'
import cex from './cex' import cex from './cex'
import ciphertrace from './ciphertrace' import ciphertrace from './ciphertrace'
import galoy from './galoy'
import infura from './infura' import infura from './infura'
import itbit from './itbit' import itbit from './itbit'
import kraken from './kraken' import kraken from './kraken'
@ -16,6 +17,7 @@ import vonage from './vonage'
export default { export default {
[bitgo.code]: bitgo, [bitgo.code]: bitgo,
[galoy.code]: galoy,
[bitstamp.code]: bitstamp, [bitstamp.code]: bitstamp,
[blockcypher.code]: blockcypher, [blockcypher.code]: blockcypher,
[infura.code]: infura, [infura.code]: infura,

View file

@ -1,4 +1,5 @@
import { useQuery, useMutation } from '@apollo/react-hooks' import { useQuery, useMutation } from '@apollo/react-hooks'
import { utils as coinUtils } from '@lamassu/coins'
import { makeStyles } from '@material-ui/core' import { makeStyles } from '@material-ui/core'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import * as R from 'ramda' import * as R from 'ramda'
@ -54,7 +55,7 @@ const ChooseExchange = ({ data: currentData, addData }) => {
const accounts = data?.accounts ?? [] const accounts = data?.accounts ?? []
const accountsConfig = data?.accountsConfig ?? [] const accountsConfig = data?.accountsConfig ?? []
const coin = currentData.coin const coin = coinUtils.getExternalCryptoCode(currentData.coin)
const exchanges = getItems(accountsConfig, accounts, 'exchange', coin) const exchanges = getItems(accountsConfig, accounts, 'exchange', coin)
const submit = () => { const submit = () => {

View file

@ -1,4 +1,5 @@
import { useQuery } from '@apollo/react-hooks' import { useQuery } from '@apollo/react-hooks'
import { utils as coinUtils } from '@lamassu/coins'
import { makeStyles } from '@material-ui/core' import { makeStyles } from '@material-ui/core'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import * as R from 'ramda' import * as R from 'ramda'
@ -34,7 +35,7 @@ const ChooseTicker = ({ data: currentData, addData }) => {
const accounts = data?.accounts ?? [] const accounts = data?.accounts ?? []
const accountsConfig = data?.accountsConfig ?? [] const accountsConfig = data?.accountsConfig ?? []
const coin = currentData.coin const coin = coinUtils.getExternalCryptoCode(currentData.coin)
const tickers = getItems(accountsConfig, accounts, 'ticker', coin) const tickers = getItems(accountsConfig, accounts, 'ticker', coin)
const submit = () => { const submit = () => {

View file

@ -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 => const isLocalHosted = it =>
R.contains(it)([ R.contains(it)([
@ -167,6 +168,19 @@ const ChooseWallet = ({ data: currentData, addData }) => {
/> />
</> </>
)} )}
{selected === 'galoy' && (
<>
<H4 noMargin>Enter wallet information</H4>
<FormRenderer
value={accounts.galoy}
save={saveWallet(selected)}
elements={schema.galoy.elements}
validationSchema={schema.galoy.getValidationSchema(accounts.galoy)}
buttonLabel={'Continue'}
buttonClass={classes.formButton}
/>
</>
)}
</div> </div>
) )
} }