Skip to content

Commit

Permalink
support staging
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Aug 10, 2024
1 parent ea540c8 commit b7b4e46
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
26 changes: 26 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,32 @@ export const blinkSchema = object({
})
})

export const blinkStagingSchema = object({
apiKey: string()
.required('required')
.test(async (nwcUrl, context) => {
try {
await string().required('required').validate(nwcUrl)
await string().matches(/^galoy_staging_[A-Za-z0-9]+$/, { message: 'must match pattern galoy_staging_A-Za-z0-9' }).validate(nwcUrl)
} catch (err) {
return context.createError({ message: err.message })
}
return true
}),
currency: string()
.transform(value => value.toUpperCase())
.default('BTC')
.test(async (currency, context) => {
try {
const supportedCurrencies = ['USD', 'BTC']
await string().required('required').oneOf(supportedCurrencies, 'must be one of ' + supportedCurrencies.join(', ')).validate(currency)
} catch (err) {
return context.createError({ message: err.message })
}
return true
})
})

export const lncSchema = object({
pairingPhrase: array()
.transform(function (value, originalValue) {
Expand Down
7 changes: 4 additions & 3 deletions wallets/blink/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { blinkSchema } from '@/lib/validate'
import { blinkSchema, blinkStagingSchema } from '@/lib/validate'

export const galoyBlinkUrl = ''
export const galoyStaging = false
export const galoyBlinkUrl = galoyStaging ? 'https://api.staging.galoy.io/graphql' : 'https://api.blink.sv/graphql'
export const galoyBlinkDashboardUrl = 'https://dashboard.blink.sv/'

export const name = 'blink'
Expand Down Expand Up @@ -30,4 +31,4 @@ export const card = {
badges: ['send only']
}

export const fieldValidation = blinkSchema
export const fieldValidation = galoyStaging ? blinkStagingSchema : blinkSchema

0 comments on commit b7b4e46

Please sign in to comment.