Skip to content

Commit ba9a68a

Browse files
authored
Merge pull request #6028 from EdgeApp/matthew/changelly-integration
Feat: Changelly integration
2 parents 32ac597 + 2c377f4 commit ba9a68a

7 files changed

Lines changed: 54 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased (develop)
44

5+
- added: Changelly swap provider
56
- added: NYM swap provider (`nymswap`)
67
- added: Optional Bridgeless swap referral id via the `BRIDGELESS_INIT` env config, passed through to the swap plugin.
78
- changed: Route maestro test builds to a dedicated Zealot channel so they no longer appear in the production release list.

scripts/obfuscateString.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Generates the obfuscated char-code array to paste into env.json for
2+
// fields cleaned by asObfuscatedString.
3+
//
4+
// Usage:
5+
// node -r sucrase/register scripts/obfuscateString.ts <plaintext...>
6+
7+
import { wasObfuscatedString } from '../src/util/cleaners/asObfuscatedString'
8+
9+
const plaintext = process.argv.slice(2).join(' ')
10+
11+
if (plaintext === '') {
12+
console.error('Usage: obfuscateString.ts <plaintext>')
13+
process.exit(1)
14+
}
15+
16+
console.log(JSON.stringify(wasObfuscatedString(plaintext)))

src/actions/CategoriesActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ export const pluginIdIcons: Record<string, string> = {
712712
bridgeless: EDGE_CONTENT_SERVER_URI + '/bridgeless.png',
713713
changenow: EDGE_CONTENT_SERVER_URI + '/changenow.png',
714714
changehero: EDGE_CONTENT_SERVER_URI + '/changehero.png',
715+
changelly: EDGE_CONTENT_SERVER_URI + '/changelly.png',
715716
cosmosibc: EDGE_CONTENT_SERVER_URI + '/cosmosibc.png',
716717
exolix: EDGE_CONTENT_SERVER_URI + '/exolix-logo.png',
717718
fantomsonicupgrade: EDGE_CONTENT_SERVER_URI + '/fantomsonicupgrade.png',

src/components/modals/SwapVerifyTermsModal.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const pluginData: Record<string, TermsUri> = {
3131
privacyUri: 'https://changenow.io/privacy-policy',
3232
kycUri: 'https://changenow.io/faq/kyc'
3333
},
34+
changelly: {
35+
termsUri: 'https://changelly.com/terms-of-use',
36+
privacyUri: 'https://changelly.com/privacy-policy',
37+
kycUri: 'https://changelly.com/aml-kyc'
38+
},
3439
exolix: {
3540
termsUri: 'https://exolix.com/terms',
3641
privacyUri: 'https://exolix.com/privacy',

src/envConfig.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { asInitOptions as asPaybisInitOptions } from './plugins/ramps/paybis/pay
1919
import { asInitOptions as asRevolutInitOptions } from './plugins/ramps/revolut/revolutRampTypes'
2020
import { asInitOptions as asSimplexInitOptions } from './plugins/ramps/simplex/simplexRampTypes'
2121
import { asBase16 } from './util/cleaners/asHex'
22+
import { asObfuscatedString } from './util/cleaners/asObfuscatedString'
2223

2324
function asNullable<T>(cleaner: Cleaner<T>): Cleaner<T | null> {
2425
return function asNullable(raw) {
@@ -274,6 +275,16 @@ export const asEnvConfig = asObject({
274275
apiKey: asOptional(asString, '')
275276
}).withRest
276277
),
278+
CHANGELLY_INIT: asCorePluginInit(
279+
asObject({
280+
// Arrays of XOR-masked char codes; see asObfuscatedString.
281+
// No fallback values: the plugin itself refuses to load when either
282+
// member is missing, so a partial entry disables Changelly instead of
283+
// supplying placeholder credentials.
284+
apiKey: asOptional(asObfuscatedString),
285+
partnerId: asOptional(asString)
286+
}).withRest
287+
),
277288
COREUM_INIT: asCorePluginInit(asBoolean),
278289
COSMOSHUB_INIT: asCorePluginInit(asBoolean),
279290
DASH_INIT: asCorePluginInit(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { asArray, asCodec, asNumber, uncleaner } from 'cleaners'
2+
3+
// XOR mask applied to each char code. Not a secret.
4+
const MASK = 0x5a
5+
6+
/**
7+
* Decodes a string stored as an array of XOR-masked char codes,
8+
* e.g. "hi" <-> [0x32, 0x33]. Use `wasObfuscatedString` or
9+
* scripts/obfuscateString.ts to generate the array.
10+
*/
11+
export const asObfuscatedString = asCodec<string>(
12+
raw =>
13+
asArray(asNumber)(raw)
14+
.map(code => String.fromCharCode(code ^ MASK))
15+
.join(''),
16+
clean => clean.split('').map(ch => ch.charCodeAt(0) ^ MASK)
17+
)
18+
19+
export const wasObfuscatedString = uncleaner(asObfuscatedString)

src/util/corePlugins.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const swapPlugins = {
9292
// Centralized Swaps
9393
changehero: ENV.CHANGEHERO_INIT,
9494
changenow: ENV.CHANGE_NOW_INIT,
95+
changelly: ENV.CHANGELLY_INIT,
9596
exolix: ENV.EXOLIX_INIT,
9697
godex: ENV.GODEX_INIT,
9798
lifi: ENV.LIFI_INIT,

0 commit comments

Comments
 (0)