Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions src/constants/plugins/exchangeInfo2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"exchangeInfo2": {
"buy": {
"providerPriority": {
"credit": {
"banxa": 1,
"moonpay": 2
}
}
},
"sell": {
"providerPriority": {
"applepay": {
"paybis": 1,
"moonpay": 2
}
},
"disableAssets": {
"monero": true,
"ethereum": ["7ef59387f0c04eb8a6d8495af829387f0c04eb8a"]
},
"disableProviders": {
"paybis": true,
"moonpay": {
"bitcoin": true,
"ethereum": [null, "af829387f0c04eb8a6d8495af829387f0c04eb8a"]
}
},
"disableRegions": [
{
"countryCode": "UK"
},
{
"countryCode": "US",
"stateProvinces": ["NY", "HI"]
},
{
"countryCode": "CA",
"stateProvinces": ["AL"],
"disableProviders": {
"paybis": true,
"moonpay": {
"bitcoin": true,
"ethereum": [null, "af829387f0c04eb8a6d8495af829387f0c04eb8a"]
}
}
}
]
},
"swap": {
"providerInfo": {
"thorchain": {
"midgardServers": ["https://midgard.thorchain.info", "https://midgard.thorchain.org"]
}
},
"providerPriority": {
"swapuz": 1,
"changenow": 2,
"godex": 0
},
"disableProviders": {
"swapuz": true,
"changenow": {
"bitcoin": true,
"ethereum": [null, "af829387f0c04eb8a6d8495af829387f0c04eb8a"]
}
},
"disableAssets": {
"monero": true,
"ethereum": ["7ef59387f0c04eb8a6d8495af829387f0c04eb8a"]
}
}
}
}
63 changes: 63 additions & 0 deletions src/constants/plugins/exchangeInfo2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { asArray, asBoolean, asEither, asNumber, asObject, asOptional, asUnknown, asString } from 'cleaners'
import { asEdgeTokenId } from '../../types/types'

// Cleaner for provider priority mapping
const asProviderPriority = asObject(asObject(asNumber))

// Cleaner for disable assets mapping - can be boolean or array of strings
const asDisableAssets = asObject(asEither(asBoolean, asArray(asEdgeTokenId)))

// Cleaner for disable providers mapping - can be boolean or object with asset-specific settings
const asDisableProviders = asObject(asEither(asBoolean, asObject(asEither(asBoolean, asArray(asEdgeTokenId)))))

// Cleaner for provider info (like thorchain midgard servers)
const asProviderInfo = asObject(asUnknown)

// Cleaner for disable regions - array of region objects with country code and optional state/province restrictions
const asDisableRegion = asObject({
countryCode: asString,
stateProvinces: asOptional(asArray(asString), () => []),
disableProviders: asOptional(asDisableProviders, () => ({}))
})

// Cleaner for buy/sell section
const asBuySellSection = asObject({
providerPriority: asOptional(asProviderPriority, () => ({})),
disableAssets: asOptional(asDisableAssets, () => ({})),
disableProviders: asOptional(asDisableProviders, () => ({})),
disableRegions: asOptional(asArray(asDisableRegion), () => [])
})

// Cleaner for swap section
const asSwapSection = asObject({
providerInfo: asOptional(asObject(asProviderInfo), () => ({})),
providerPriority: asOptional(asProviderPriority, () => ({})),
disableProviders: asOptional(asDisableProviders, () => ({})),
disableAssets: asOptional(asDisableAssets, () => ({}))
})

// Main cleaner for exchangeInfo2
export const asExchangeInfo2 = asObject({
exchangeInfo2: asObject({
buy: asOptional(asBuySellSection, () => ({
providerPriority: {},
disableAssets: {},
disableProviders: {},
disableRegions: []
})),
sell: asOptional(asBuySellSection, () => ({
providerPriority: {},
disableAssets: {},
disableProviders: {},
disableRegions: []
})),
swap: asOptional(asSwapSection, () => ({
providerInfo: {},
providerPriority: {},
disableProviders: {},
disableAssets: {}
}))
})
})

export type ExchangeInfo2 = ReturnType<typeof asExchangeInfo2>
Loading