From b5e416798eafda94118167f03b4f9f1099513fb9 Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Mon, 11 Aug 2025 18:16:46 -0700 Subject: [PATCH] exchangeInfo2 --- src/constants/plugins/exchangeInfo2.json | 74 ++++++++++++++++++++++++ src/constants/plugins/exchangeInfo2.ts | 63 ++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 src/constants/plugins/exchangeInfo2.json create mode 100644 src/constants/plugins/exchangeInfo2.ts diff --git a/src/constants/plugins/exchangeInfo2.json b/src/constants/plugins/exchangeInfo2.json new file mode 100644 index 00000000000..3c3560b539d --- /dev/null +++ b/src/constants/plugins/exchangeInfo2.json @@ -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"] + } + } + } +} diff --git a/src/constants/plugins/exchangeInfo2.ts b/src/constants/plugins/exchangeInfo2.ts new file mode 100644 index 00000000000..6ae004be17e --- /dev/null +++ b/src/constants/plugins/exchangeInfo2.ts @@ -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