From 085ddf26dbef9028c1edccd5db9d9f009593f851 Mon Sep 17 00:00:00 2001 From: Paul V Puey Date: Tue, 3 Jan 2023 21:53:34 -0800 Subject: [PATCH 1/4] Upgrade dev dep edge-core-js for newer types --- package.json | 3 ++- yarn.lock | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2c7c21d6..6d303c83 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "@types/node-fetch": "2.x", "@types/request": "^2.48.7", "@types/url-parse": "^1.4.3", + "@types/utf8": "^3.0.1", "@types/ws": "^7.2.6", "@typescript-eslint/eslint-plugin": "^4.8.2", "@typescript-eslint/parser": "^4.8.2", @@ -75,7 +76,7 @@ "buffer": "^6.0.3", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", - "edge-core-js": "^0.19.33", + "edge-core-js": "^0.19.36", "eslint": "^7.14.0", "eslint-config-standard-kit": "0.15.1", "eslint-plugin-flowtype": "^5.2.0", diff --git a/yarn.lock b/yarn.lock index 45330a56..8abb55f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1463,6 +1463,11 @@ resolved "https://registry.yarnpkg.com/@types/url-parse/-/url-parse-1.4.8.tgz#c3825047efbca1295b7f1646f38203d9145130d6" integrity sha512-zqqcGKyNWgTLFBxmaexGUKQyWqeG7HjXj20EuQJSJWwXe54BjX0ihIo5cJB9yAQzH8dNugJ9GvkBYMjPXs/PJw== +"@types/utf8@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@types/utf8/-/utf8-3.0.1.tgz#bf081663d4fff05ee63b41f377a35f8b189f7e5b" + integrity sha512-1EkWuw7rT3BMz2HpmcEOr/HL61mWNA6Ulr/KdbXR9AI0A55wD4Qfv8hizd8Q1DnknSIzzDvQmvvY/guvX7jjZA== + "@types/ws@^7.2.6": version "7.4.7" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" @@ -2650,10 +2655,10 @@ duplexer3@^0.1.4: resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= -edge-core-js@^0.19.33: - version "0.19.33" - resolved "https://registry.yarnpkg.com/edge-core-js/-/edge-core-js-0.19.33.tgz#55129d6d15d3da4dd3221eedc62684e071b99d3d" - integrity sha512-OIXQAGYS3cxAsU64lMA7ppU539sAGFdpv/Ss7RI3L4SJQhom5J2m74nvm1Y7vSXj78tH5bTNHqh9nClck34VsQ== +edge-core-js@^0.19.36: + version "0.19.36" + resolved "https://registry.yarnpkg.com/edge-core-js/-/edge-core-js-0.19.36.tgz#8404fb4f181c2017ab6df9ea21564481e27f0427" + integrity sha512-a4D/ozsXLYW1AesXx4hZ2ZKvrFK5QIdlgm1e1LlZ/ZGkXYqY43skHnTnz0HMnL3rAbG7756xwqIEv5iBD0E6uQ== dependencies: aes-js "^3.1.0" base-x "^1.0.4" From 3846811962ba1d1d9a1438d2ef6224a6ae83ea58 Mon Sep 17 00:00:00 2001 From: Paul V Puey Date: Tue, 3 Jan 2023 22:34:48 -0800 Subject: [PATCH 2/4] Add Changelly plugin Only allowed for Piratechain swaps with FROM quotes --- src/index.ts | 2 + src/swap/changelly.ts | 481 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 483 insertions(+) create mode 100644 src/swap/changelly.ts diff --git a/src/index.ts b/src/index.ts index 8c5dd2e7..25d2269c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import { makeEdgeRatesPlugin } from './rate/edgeRates' import { makeNomicsPlugin } from './rate/nomics' import { makeWazirxPlugin } from './rate/wazirx' import { makeChangeHeroPlugin } from './swap/changehero' +import { makeChangellyPlugin } from './swap/changelly' import { makeChangeNowPlugin } from './swap/changenow' import { makeThorchainPlugin } from './swap/defi/thorchain' import { makeThorchainDaPlugin } from './swap/defi/thorchainDa' @@ -39,6 +40,7 @@ const edgeCorePlugins = { // Swap plugins: changehero: makeChangeHeroPlugin, + changelly: makeChangellyPlugin, changenow: makeChangeNowPlugin, exolix: makeExolixPlugin, godex: makeGodexPlugin, diff --git a/src/swap/changelly.ts b/src/swap/changelly.ts new file mode 100644 index 00000000..666a0751 --- /dev/null +++ b/src/swap/changelly.ts @@ -0,0 +1,481 @@ +import { lt } from 'biggystring' +import { asBoolean, asEither, asNull, asObject, asString } from 'cleaners' +import { + EdgeCorePluginOptions, + EdgeCurrencyWallet, + EdgeSpendInfo, + EdgeSwapInfo, + EdgeSwapPlugin, + EdgeSwapQuote, + EdgeSwapRequest, + EdgeTransaction, + SwapBelowLimitError, + SwapCurrencyError +} from 'edge-core-js/types' +import hashjs from 'hash.js' +import { base16 } from 'rfc4648' +import utf8Codec from 'utf8' + +import { + checkInvalidCodes, + CurrencyCodeTranscriptionMap, + getCodesWithTranscription, + InvalidCurrencyCodes, + makeSwapPluginQuote +} from '../swap-helpers' +import { convertRequest } from '../util/utils' +import { EdgeSwapRequestPlugin } from './types' + +const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { + from: { + ethereum: ['BNB', 'FTM', 'MATIC', 'KNC'], + avalanche: 'allTokens', + binancesmartchain: 'allTokens', + polygon: 'allCodes', + celo: 'allTokens', + fantom: 'allCodes' + }, + to: { + ethereum: ['BNB', 'FTM', 'MATIC', 'KNC'], + avalanche: 'allTokens', + binancesmartchain: 'allTokens', + polygon: 'allCodes', + celo: 'allTokens', + fantom: 'allCodes', + zcash: ['ZEC'] + } +} + +const MUST_USE_CURRENCY_PLUGIN_ID = 'piratechain' + +// Invalid currency codes should *not* have transcribed codes +// because currency codes with transcribed versions are NOT invalid +const CURRENCY_CODE_TRANSCRIPTION: CurrencyCodeTranscriptionMap = { + ethereum: { + USDT: 'USDT20' + }, + binancesmartchain: { + BNB: 'BNBBSC' + } +} + +function hmacSha512(data: Uint8Array, key: Uint8Array): Uint8Array { + // @ts-expect-error + const hmac = hashjs.hmac(hashjs.sha512, key) + // @ts-expect-error + return hmac.update(data).digest() +} + +function parseUtf8(text: string): Uint8Array { + const byteString: string = utf8Codec.encode(text) + const out = new Uint8Array(byteString.length) + + for (let i = 0; i < byteString.length; ++i) { + out[i] = byteString.charCodeAt(i) + } + + return out +} + +const pluginId = 'changelly' +const swapInfo: EdgeSwapInfo = { + pluginId, + displayName: 'Changelly', + + supportEmail: 'support@changelly.com' +} + +const orderUri = 'https://changelly.com/transaction/' +const uri = 'https://api.changelly.com' +const expirationMs = 1000 * 60 +const expirationFixedMs = 1000 * 60 +const asQuoteInfo = asObject({ + result: asObject({ + id: asString, + apiExtraFee: asString, + changellyFee: asString, + payinExtraId: asEither(asString, asNull), + payoutExtraId: asEither(asString, asNull), + amountExpectedFrom: asString, + amountExpectedTo: asString, + status: asString, + currencyFrom: asString, + currencyTo: asString, + amountTo: asString, + payinAddress: asString, + payoutAddress: asString, + createdAt: asString + }) +}) + +const asFixedQuoteInfo = asObject({ + result: asObject({ + id: asString, + amountExpectedFrom: asString, + amountExpectedTo: asString, + amountTo: asString, + apiExtraFee: asString, + changellyFee: asString, + createdAt: asString, + currencyFrom: asString, + currencyTo: asString, + kycRequired: asBoolean, + payinAddress: asString, + payinExtraId: asEither(asString, asNull), + payoutAddress: asString, + payoutExtraId: asEither(asString, asNull), + refundAddress: asString, + refundExtraId: asEither(asString, asNull), + status: asString + }) +}) + +const asFixedRateQuote = asObject({ + result: asObject({ + id: asString + }) +}) + +const asQuoteReply = asObject({ + result: asString +}) + +async function getAddress( + wallet: EdgeCurrencyWallet, + currencyCode: string +): Promise { + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress +} + +function checkReply( + reply: { error?: { code?: number; message?: string } }, + request: EdgeSwapRequestPlugin +): void { + if (reply.error != null) { + if ( + reply.error.code === -32602 || + (reply.error.message?.includes('Invalid currency:') ?? false) + ) { + throw new SwapCurrencyError( + swapInfo, + request.fromCurrencyCode, + request.toCurrencyCode + ) + } + throw new Error('ChangeHero error: ' + JSON.stringify(reply.error)) + } +} + +export function makeChangellyPlugin( + opts: EdgeCorePluginOptions +): EdgeSwapPlugin { + const { initOptions, io } = opts + const { fetchCors = io.fetch } = io + + if (initOptions.apiKey == null || initOptions.secret == null) { + throw new Error('No Changelly apiKey or secret provided.') + } + const { apiKey } = initOptions + const secret = parseUtf8(initOptions.secret) + + async function call(json: any, promoCode?: string): Promise { + const body = JSON.stringify(json) + const sign = base16 + .stringify(hmacSha512(parseUtf8(body), secret)) + .toLowerCase() + + const headers: { [header: string]: string } = { + 'Content-Type': 'application/json', + 'api-key': apiKey, + sign + } + if (promoCode != null) headers['X-Promo-Code'] = promoCode + const response = await fetchCors(uri, { method: 'POST', body, headers }) + + if (!response.ok) { + throw new Error(`Changelly returned error code ${response.status}`) + } + return await response.json() + } + + async function getFixedQuote( + request: EdgeSwapRequestPlugin, + opts: { promoCode?: string } + ): Promise { + const { promoCode } = opts + const [fromAddress, toAddress] = await Promise.all([ + getAddress(request.fromWallet, request.fromCurrencyCode), + getAddress(request.toWallet, request.toCurrencyCode) + ]) + const quoteAmount = await request.fromWallet.nativeToDenomination( + request.nativeAmount, + request.fromCurrencyCode + ) + + const { fromCurrencyCode, toCurrencyCode } = getCodesWithTranscription( + request, + {}, + CURRENCY_CODE_TRANSCRIPTION + ) + + const safeFromCurrencyCode = fromCurrencyCode.toLowerCase() + const safeToCurrencyCode = toCurrencyCode.toLowerCase() + + const fixedRateQuoteResponse = await call({ + jsonrpc: '2.0', + id: 'one', + method: 'getFixRateForAmount', + params: { + from: safeFromCurrencyCode, + to: safeToCurrencyCode, + amountFrom: quoteAmount + } + }) + const fixedRateQuote = asFixedRateQuote(fixedRateQuoteResponse) + const params = { + amount: quoteAmount, + from: safeFromCurrencyCode, + to: safeToCurrencyCode, + address: toAddress, + extraId: null, + refundAddress: fromAddress, + refundExtraId: null, + rateId: fixedRateQuote.result.id + } + + const sendReply = await call( + { + jsonrpc: '2.0', + id: 2, + method: 'createFixTransaction', + params + }, + promoCode + ) + checkReply(sendReply, request) + const quoteInfo = asFixedQuoteInfo(sendReply).result + const spendInfoAmount = await request.fromWallet.denominationToNative( + quoteInfo.amountExpectedFrom, + // need to verify that this is okay + // why use currencyCode from quoteInfo in the first place? + request.fromCurrencyCode.toUpperCase() + ) + + const amountExpectedFromNative = await request.fromWallet.denominationToNative( + quoteInfo.amountExpectedFrom, + request.fromCurrencyCode + ) + const amountExpectedToTo = await request.toWallet.denominationToNative( + quoteInfo.amountExpectedTo, + request.toCurrencyCode + ) + + const spendInfo: EdgeSpendInfo = { + currencyCode: request.fromCurrencyCode, + spendTargets: [ + { + nativeAmount: spendInfoAmount, + publicAddress: quoteInfo.payinAddress, + uniqueIdentifier: quoteInfo.payinExtraId ?? undefined + } + ], + networkFeeOption: + request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard', + swapData: { + orderId: quoteInfo.id, + orderUri: orderUri + quoteInfo.id, + isEstimate: false, + payoutAddress: toAddress, + payoutCurrencyCode: request.toCurrencyCode, + payoutNativeAmount: amountExpectedToTo, + payoutWalletId: request.toWallet.id, + plugin: { ...swapInfo }, + refundAddress: fromAddress + } + } + const tx: EdgeTransaction = await request.fromWallet.makeSpend(spendInfo) + + return makeSwapPluginQuote( + request, + amountExpectedFromNative, + amountExpectedToTo, + tx, + toAddress, + 'changelly', + false, + new Date(Date.now() + expirationFixedMs), + quoteInfo.id + ) + } + + async function getEstimate( + request: EdgeSwapRequestPlugin, + opts: { promoCode?: string } + ): Promise { + const { promoCode } = opts + // Grab addresses: + const [fromAddress, toAddress] = await Promise.all([ + getAddress(request.fromWallet, request.fromCurrencyCode), + getAddress(request.toWallet, request.toCurrencyCode) + ]) + + // Convert the native amount to a denomination: + const quoteAmount = await request.fromWallet.nativeToDenomination( + request.nativeAmount, + request.fromCurrencyCode + ) + + const { fromCurrencyCode, toCurrencyCode } = getCodesWithTranscription( + request, + {}, + CURRENCY_CODE_TRANSCRIPTION + ) + + const safeFromCurrencyCode = fromCurrencyCode.toLowerCase() + const safeToCurrencyCode = toCurrencyCode.toLowerCase() + + // Swap the currencies if we need a reverse quote: + const quoteParams = { + from: safeFromCurrencyCode, + to: safeToCurrencyCode, + amount: quoteAmount + } + + // Get the estimate from the server: + const [minAmountResponse, exchangeAmountResponse] = await Promise.all([ + call({ + jsonrpc: '2.0', + id: 'one', + method: 'getMinAmount', + params: { + from: safeFromCurrencyCode, + to: safeToCurrencyCode + } + }), + call({ + jsonrpc: '2.0', + id: 'two', + method: 'getExchangeAmount', + params: quoteParams + }) + ]) + checkReply(minAmountResponse, request) + const minAmount = asQuoteReply(minAmountResponse).result + + // Check the minimum: + const nativeMin = await request.fromWallet.denominationToNative( + minAmount, + request.fromCurrencyCode + ) + if (lt(request.nativeAmount, nativeMin)) { + throw new SwapBelowLimitError(swapInfo, nativeMin) + } + + checkReply(exchangeAmountResponse, request) + + // Calculate the amounts: + const fromAmount = quoteAmount + const fromNativeAmount = request.nativeAmount + + // Get the address: + const sendReply = await call( + { + jsonrpc: '2.0', + id: 3, + method: 'createTransaction', + params: { + amount: fromAmount, + from: safeFromCurrencyCode, + to: safeToCurrencyCode, + address: toAddress, + extraId: null, // TODO: Do we need this for Monero? + refundAddress: fromAddress, + refundExtraId: null + } + }, + promoCode + ) + checkReply(sendReply, request) + const quoteInfo = asQuoteInfo(sendReply).result + + const toNativeAmount = await request.toWallet.denominationToNative( + quoteInfo.amountExpectedTo, + request.toCurrencyCode + ) + + // Make the transaction: + const spendInfo: EdgeSpendInfo = { + currencyCode: request.fromCurrencyCode, + spendTargets: [ + { + nativeAmount: fromNativeAmount, + publicAddress: quoteInfo.payinAddress, + uniqueIdentifier: quoteInfo.payinExtraId ?? undefined + } + ], + swapData: { + orderId: quoteInfo.id, + orderUri: orderUri + quoteInfo.id, + isEstimate: true, + payoutAddress: toAddress, + payoutCurrencyCode: request.toCurrencyCode, + payoutNativeAmount: toNativeAmount, + payoutWalletId: request.toWallet.id, + plugin: { ...swapInfo }, + refundAddress: fromAddress + } + } + const tx: EdgeTransaction = await request.fromWallet.makeSpend(spendInfo) + + return makeSwapPluginQuote( + request, + fromNativeAmount, + toNativeAmount, + tx, + toAddress, + 'changelly', + true, + new Date(Date.now() + expirationMs), + quoteInfo.id + ) + } + + const out: EdgeSwapPlugin = { + swapInfo, + async fetchSwapQuote( + req: EdgeSwapRequest, + userSettings: Object | undefined, + opts: { promoCode?: string } + ): Promise { + const request = convertRequest(req) + checkInvalidCodes(INVALID_CURRENCY_CODES, request, swapInfo) + // Only allow FROM quotes + if (request.quoteFor !== 'from') { + throw new SwapCurrencyError(swapInfo, req) + } + + if ( + request.fromWallet.currencyInfo.pluginId !== + MUST_USE_CURRENCY_PLUGIN_ID && + request.toWallet.currencyInfo.pluginId !== MUST_USE_CURRENCY_PLUGIN_ID + ) { + throw new SwapCurrencyError(swapInfo, req) + } + + // Hack to make lint happy so we don't have to comment out getFixedQuote + console.log(getFixedQuote.name) + // const fixedPromise = getFixedQuote(request, opts) + const estimatePromise = getEstimate(request, opts) + // try { + // const fixedResult = await fixedPromise + // return fixedResult + // } catch (e) { + const estimateResult = await estimatePromise + return estimateResult + // } + } + } + + return out +} From 8809932a8fd5a419c1baaeb59a21bcd9a971bd99 Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Tue, 3 Jan 2023 21:58:31 -0800 Subject: [PATCH 3/4] Update testing files --- test/createUserDump.ts | 7 +++ test/fakeArrrInfo.ts | 38 +++++++++++++++ test/fakeUserDump.json | 103 ++++++++++++++++++++++++++++++++++++++++- test/testpartner.ts | 51 +++++++++++++++++++- 4 files changed, 196 insertions(+), 3 deletions(-) create mode 100644 test/fakeArrrInfo.ts diff --git a/test/createUserDump.ts b/test/createUserDump.ts index 902b0b3f..c81d2ebc 100644 --- a/test/createUserDump.ts +++ b/test/createUserDump.ts @@ -7,6 +7,7 @@ import { import fs from 'fs' import edgeExchangePlugins from '../src' +import { arrrCurrencyInfo } from './fakeArrrInfo' import { avaxCurrencyInfo } from './fakeAvaxInfo' import { btcCurrencyInfo } from './fakeBtcInfo' import { makeFakePlugin } from './fakeCurrencyPlugin' @@ -19,6 +20,7 @@ async function main(): Promise { bitcoin: makeFakePlugin(btcCurrencyInfo), ethereum: makeFakePlugin(ethCurrencyInfo), avalanche: makeFakePlugin(avaxCurrencyInfo), + piratechain: makeFakePlugin(arrrCurrencyInfo), ...edgeExchangePlugins } @@ -35,6 +37,7 @@ async function main(): Promise { bitcoin: true, ethereum: true, avalanche: true, + piratechain: true, thorchainda: true } }) @@ -43,6 +46,10 @@ async function main(): Promise { fiatCurrencyCode: 'iso:EUR', name: 'My Fake Bitcoin' }) + await account.createCurrencyWallet('wallet:piratechain', { + fiatCurrencyCode: 'iso:EUR', + name: 'My Fake Arrr' + }) const ethWallet = await account.createCurrencyWallet('wallet:ethereum', { fiatCurrencyCode: 'iso:EUR', name: 'My Fake Bitcoin' diff --git a/test/fakeArrrInfo.ts b/test/fakeArrrInfo.ts new file mode 100644 index 00000000..edb3ad89 --- /dev/null +++ b/test/fakeArrrInfo.ts @@ -0,0 +1,38 @@ +import { EdgeCurrencyInfo } from 'edge-core-js' + +import { FakeSettings } from './fakeCurrencyPlugin' + +const defaultSettings: FakeSettings = { + customFeeSettings: ['gasLimit', 'gasPrice'], + publicAddress: + 'zs15f7lcslcxuvrd2wutasl35zyxp0uw9nkk75e8euuydp93qug0reuf70l48hc8fgp7ngcu8qkvcf', + networkFee: '100000000000000', + parentNetworkFee: '1000000000000000', + balances: { + ARRR: '100000' // balances in exchange amount + } +} + +export const arrrCurrencyInfo: EdgeCurrencyInfo = { + // Basic currency information: + currencyCode: 'ARRR', + displayName: 'Pirate Chain', + pluginId: 'piratechain', + requiredConfirmations: 10, + walletType: 'wallet:piratechain', + + defaultSettings, + + addressExplorer: 'https://explorer.pirate.black/address/%s', + transactionExplorer: 'https://explorer.pirate.black/tx/%s', + + denominations: [ + // An array of Objects of the possible denominations for this currency + { + name: 'ARRR', + multiplier: '100000000', + symbol: 'P' + } + ], + metaTokens: [] +} diff --git a/test/fakeUserDump.json b/test/fakeUserDump.json index 4e977d89..eab75f77 100644 --- a/test/fakeUserDump.json +++ b/test/fakeUserDump.json @@ -1 +1,102 @@ -{"loginKey":"5pz3t88fWVYJExd7mLs86PYQ62NiNgRGK547zzoPs4SW","data":{"lastLogin":"2022-11-18T21:18:31.039Z","loginId":"3EDixdDPeWBLWthJy8vR3PENlRj5AVaGyHOmMK31bO0=","loginKey":"R7mNUJCr9zohkxD4YQubOktfRkSbbAzOMXVYm2ikyeM=","repos":{"6a0e84cbe4d519fed9c1115f83c4de36897e32cd":{},"a5211c7ec5f671c5913218088d15fc5136336cf6":{},"4d9fc87fbc56d1ab7c9ed414c5a19cc0e3de23b7":{},"74d438caa5e9b76d9e6855d9eecbd266baf3ad8e":{}},"server":{"appId":"","created":"2022-11-18T21:18:33.227Z","loginId":"3EDixdDPeWBLWthJy8vR3PENlRj5AVaGyHOmMK31bO0=","children":[],"passwordAuth":"DXKVL9TnxYNbycdPz1cSxrXK+CQ1dmL3aaE5598KYiA=","passwordAuthBox":{"encryptionType":0,"data_base64":"MguhSNchzGaYtAnh6Tl91HdjqpI31EnMssEMn08Pt312l0D8fBGwR2m3SkF7hZ22AVC6e6HiOoo0npW9si/EuKi3VF4rUxlnK+dabBsXLd60K7XjoTQZNoF2y+Hn/R2Ywp2biG+5wj8PDuhM4HAGbX9smO3DAGn9jkwvtSykGDdCK6w/FNGusEtL4HLnC1xL","iv_hex":"3888CE05B8B3B51F6531DDEB68DB19D5"},"passwordAuthSnrp":{"salt_hex":"b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b","n":16384,"r":1,"p":1},"passwordBox":{"encryptionType":0,"data_base64":"fGNh5O0S9USSk4Cwe0cCtGH8HsYnY2pa6aRNUjdqFfJxdZVuVXX0BrvLu2qh/fwPopfELNHUdd8iMk9m36r45CtduQHtKe2KRR05pASkxlu/LiJcdzNEQIUO2qJhV1gCh5wMMk2r8yvu2oIbCGE+zg==","iv_hex":"0CDA6E454A4D4EC61822E2450A626059"},"passwordKeySnrp":{"salt_hex":"997e62de4f679a6a7af125d19dbaeeefbf40ead801672a204d8cbcab499625a0","n":131072,"r":8,"p":2},"pin2Id":"PER1abZslMixETL5hmpv+gC8q1WPpdMzDyvMlkgzhN4=","pin2Auth":"t5HfqPf3S5AlRVOtiaHxf9t9YYSMdnF1sq8zmkrjL5A=","pin2Box":{"encryptionType":0,"data_base64":"hYln+7e26pdP5CIjqvBhWbaeH+CPU79FxCync/loUs7TYdkHUz40lrW5jpWI3gyRQTGjE2Dv1NxZtpZYJB3tjKBNM6B6NThE0ihwFmWvV7wzQb2hRZpy1I2mNfJ9NEb1tT8MUTOodTvBhkt/jnbQGQ==","iv_hex":"E6666886A31505F50B33F3BF46344074"},"pin2KeyBox":{"encryptionType":0,"data_base64":"B0gFbCkfqTH/HcQr36t3nEPsUwRbSrR7S0dzKHV6Jyw0nQlCiSEFCsmk7qfYHORfJNo7AtyPZTQd7UpYzpkvyfrTd9AJkBoS+0REgFka4u/CjHafaizBDtRriBUJwdrLxHfE1VSxwRvn3/I8gWIK4w==","iv_hex":"8400199922AAEA5EFE79B194FF1A729F"},"pin2TextBox":{"encryptionType":0,"data_base64":"q+cEz3T0A4CC00FlmKjJrholbFssai0Wdt0ZnpshK+UPAsjI6sXphCeDs7GZyHiy77pmemwNN5gSCYjiVC4LcNnhGSscCotWsYvIimyPfNI=","iv_hex":"179328C94BB6232E1CF78D9837B3E091"},"loginAuth":"c/LB1skx3JVwyS0Wb1DX9vkPOvOlK859xOfe3aBkS8c=","loginAuthBox":{"encryptionType":0,"data_base64":"/Sm7vypAY0fKEiYIQqWXlIQAuc2/sfGDixLJo3khY08M47GPiQ+RZ2FcR4hZ1HRP6rtfELBgXMd5QNkTMayJ9MHtRn1opHVdKDlxE5DaLNW6UMcFjJ1TZhtv8u8XC37p","iv_hex":"95BF40B6FADB09CC88641518B275EFA5"},"userId":"cBZr4QmjcqKzb0P8bSn0xKyHYPJvYmhSgUO5X5KODUI=","userTextBox":{"encryptionType":0,"data_base64":"CnYrxIQhZNeXjK6VJTG7vZhiIaiz3xXrroYfUUNJUU0/YlhiB53cR54XwMW6psqPJ7YbwABUIysDG++7p4nUOA==","iv_hex":"79391DE112846161A8C97E9574E224A3"},"keyBoxes":[{"encryptionType":0,"data_base64":"oQoEDNWXgHibVW8hfQcAjh68agq5Ud7XBI98CgrzKEy56SjGdOkHcxEFtog8dmVA8qM/Zbq8Yq2XmIearDejs94IW9v7XmaBM7C95ZNQ3YIrfz4oSGA5hzf8a+AA1Ct42gWI6DwdqqAGCzQ5WaIYLfsRLulx8bNiAfhG7/ubt9Kr4sa0TQinRufOpxqSYDYArRPLmuCutadVehS5/PkHpCvo7cu+dDVddEbI1yTCbA+ws4Y8w+otdWYpFgjKjHbEiKb05ngeektdAoTfFip8mywZzmAleDso43wOeqN6xiii1xDsY786qgDQEtQJ+NJDJI9NOT39zoTCmrNLR5CP5g==","iv_hex":"B613266CE1FE3104814F653E541BCECC"},{"encryptionType":0,"data_base64":"url2UHFtytE33MktXBHZkh0WtErnhLM8mr39aAoxx6dBmQjAS6Jr/6iC7RWmKyi5KSGgjUsliSfjWDMTAEPY7fchT1l+34dW/rY5mWrhl4VKv6XmPYC41JTuboC0TpLAziKuuMf1Q3QTB/A+AZhlU/aTiLGpYo1G1LmVCd6oXQi2DfbXnkFyl3MYNkggBkKTgwMvDlIeOf9psRK4OLbArBvzyYFtG/ZmSsYAKrS8f7YbOrrotxEjkVdgDyIcGFnlj8ykp2/CDvm3/NsmpJDQgDW5lHlx3Em1hmGx9f76pZyykThS/IaMzO/DK8A8QQVH7qni1kQt/gTYd6AryiTk0bdrc2Vawc1rLul6+giEuxsRI2AkV0GXXabIf3az67SWR4HMv1jFNnv4bK/Cj43d4w==","iv_hex":"1F1AC3FEBEFD3C7F5D918C7AF9081C49"},{"encryptionType":0,"data_base64":"FffCFWSbbbTyoN+oSsN+CV+seRp9otSTfZ+sS8o+fj12yO0ohh24sUafS0OduvWMJBD4CYIoQbPdBTYKCNmJeP5S8lKQv8+0Lye7eUEyXQy4GqhbRXUF3VNrxn/6RekhZpvHkWYAYfwlrKxdYeaw+phK0VDDOnUnk9bIWSDFza5a/Xdkw85xqIhg//tJ054f1u47hjWP0MYdzvYVhokFFjegX28Qdoo3pC/U0ulpdMGrXr732ZnfSKfb6p2mcEJ+HaQyymQNIr8p/5TXsqps+O3xRANyinHbvIypzOK3FiwfobmOlu2cNx7NOCXbJRiynvfQ+Vm7RLAI8gRZsOesiJ1l7+kQEwDU2rjQCSv11FFr3VskXts9VMYfbk2CKpks1mjErRWPNgBxiITRFQprnQ==","iv_hex":"88A8D16684DC718E8D9A87C0D228373A"},{"encryptionType":0,"data_base64":"qGll6Sm3MXO1Wb2I8f87YY5uR1WFKo6FoDB6YEYjoBsc59uRldyYplh1M/KTo2+JWXWPgXceV0k6pLo9Pzm5UIH5RaXnrsDlwj4LDFbymxUWuG3vWAEBRoG3qVEMdbIiKgMMryyub4j7Q/LvROOyEvwSqMVu9sQDxQf66Qoi+GQtn/PVwWjyMaPlTfjEeAXHJ04xKhzcPpdbemDrQojAum4KOOwW4k0FtgGC/WM2mGfVqB/SEdaTOfqwFwdvbHt0E4sotuaOHpCA/U2fPs+P7moZ/3yWlyv5tbkmx66haQsFuSHX+k/9SnYTKTvVmHjZXvo1YJKdCPkMWCNjBOmfrF0oazvDPjWOv9qTo4dEW0MtV2Np4WCb9BV1HtPw90rD","iv_hex":"C2C9BC9B253B578978E9A2CB7ADA1671"}],"vouchers":[]},"username":"bob"}} \ No newline at end of file +{ + "loginKey": "2crr9B88Xt1kkAKdcP1ZM6VmWbKTCwZJRtnfqmqd2wHP", + "data": { + "lastLogin": "2023-01-04T05:06:14.748Z", + "loginId": "d10/rBEyFnGvQ1zHxoL+TSkFHSZ2Me6vkRggRKcVMgo=", + "loginKey": "GAtgsh1+vOQ7dfrMzKfkJhhYNiGLPuN5xL0MxbpEhrY=", + "repos": { + "4ef53b65a751e6c55976f955a59413914c63b624": {}, + "5b8d2e7e9887323d2960100747620c3a50726104": {}, + "794e8893573f158a763e766428a2b86c1bd11c94": {}, + "c9c49928a8e33728c5333f8aa80a0710fc398e58": {}, + "b8223f704be1b4f4e6da697058865d4dd152e856": {} + }, + "server": { + "appId": "", + "created": "2023-01-04T05:06:16.917Z", + "loginId": "d10/rBEyFnGvQ1zHxoL+TSkFHSZ2Me6vkRggRKcVMgo=", + "children": [], + "passwordAuth": "DXKVL9TnxYNbycdPz1cSxrXK+CQ1dmL3aaE5598KYiA=", + "passwordAuthBox": { + "encryptionType": 0, + "data_base64": "XXDE4jhy1MjEska6B5Ed8yrdiZpJluFK3uPZffnAk2ClaL5SfRlnmnRscVOK50b5mj95bB3xlFrBfBDyH+xuO+HHJ1Pj+hwXFNtznTDC9A+ca5xnb5OJpmqrMRuXQqNz18ca6wIoMX6DUbKffkezcA==", + "iv_hex": "4A2A169588C4FC6C80C72D57A3875774" + }, + "passwordAuthSnrp": { + "salt_hex": "b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b", + "n": 16384, + "r": 1, + "p": 1 + }, + "passwordBox": { + "encryptionType": 0, + "data_base64": "CupAgixXMdpe4wWrSAHQeiTrDCvxLX/RCWzcS+IPUO9CYkfDLZpbNjRy53gANLwwgwOvbJHMNyYb5JfuqXEDjzLxSF+94eFXkE6k2CTexDY=", + "iv_hex": "60C4F5C0C9E24B2DF5469757C238E827" + }, + "passwordKeySnrp": { + "salt_hex": "b6d64801c8e080a086c86f4f489013946d00bbfbe9a9defb48fbe78c55daaa29", + "n": 131072, + "r": 8, + "p": 2 + }, + "pin2Id": "FiE0SdA77HT3jFbNZcrn/Qa1dU4HIluKbGt7PbmBE+Y=", + "pin2Auth": "xwTYcY6sZo1+KHOhcoRekFOu8undJlj1q8sEQEJZGlc=", + "pin2Box": { + "encryptionType": 0, + "data_base64": "AjwhMr9AzwxvgSND3UZcJmUjJgukXVzumglsKy9r5OXPcfeU2RpWDAchu8H/0rKJLWhHiU8LX2XqrVrf8XjLUnXPa9wEMVtAikvQtPZsR4wB3B2XyaejFjbBbHXII9cb+IIpZzguaf+s2U3vSp667Q==", + "iv_hex": "B3149649B1C23B96B7AF1456575FBBB6" + }, + "pin2KeyBox": { + "encryptionType": 0, + "data_base64": "AVR91nmpKUhLeQyUWIu11eOicKD7Um8Eiyzp8ZhKsMNiiCkbPPG3gBtn4pgniboaPsfHoCeKobYJHA5Vlh8zY5zi/hnojEBaAWjS4Zm2QoVi7vu9T3xnKUuu/i2q44l93M6q8KnajkuI2oTRS7l+vQ==", + "iv_hex": "7C0E1C4254BDC0A94AA92A8CD20EE246" + }, + "pin2TextBox": { + "encryptionType": 0, + "data_base64": "gl+w/8FQ0h4N/5dY4S1uQ/OQQOh5XTz/I/lgPfrFaCRRjT7KYD2hKzWimO+rJLNZtQkrVhwjVSctgBEbUhhLUuRagUWVCViw9UshQLpJCPTcCex6ltqf0SpgW3dK19B0", + "iv_hex": "198A4485AE5582D113F2C09F7B916016" + }, + "loginAuth": "u/RjcRYWwZtu2YK8QCA60ND2prj20CjmRjdXoWU+uiU=", + "loginAuthBox": { + "encryptionType": 0, + "data_base64": "ERnco3MYmuVh3MSlTnNTRYu/Uknmytg0Vkzv/tmdqwz+TFOhMTx024kpoYs0jAzWcGaohRj2VKHe17B3g9o3Pot7J5ee3gkX1L1QAAYeOHw=", + "iv_hex": "A3F3017AC9D0BE8679B9C0945DD7A017" + }, + "userId": "cBZr4QmjcqKzb0P8bSn0xKyHYPJvYmhSgUO5X5KODUI=", + "userTextBox": { + "encryptionType": 0, + "data_base64": "mrsj0m+HVjjUMKimZr573JZ07ikbXRUu9KyFTvgCxHa7YKBCQLwmKbhy0wI6iVlzbUwyAepCAreArjRE4LO/owiKnKuKzDm+xozacfVQeNCymPNJ0NEZGyyEe7cCUoLS", + "iv_hex": "5944800FB231C52820A08A3A7257F958" + }, + "keyBoxes": [ + { + "encryptionType": 0, + "data_base64": "jdUC/xS7HFgK4FjvrNqBhnSqm2eP5hYdUKcdFb6c+begX0ZNbtXSBYAdq2wjwY0qJRHRh+hiATVl847MwRSZO5iBbBVbaIFprCLU2Yw/XM1JCj1HZIH3+QIwRMFZPTBAAyCwWJw8w0UgaAfmv35A5+sKgRBtcKyXtbg60xv/o5js1dNTBpq9Ib0mH/ez7pfCUfPQ72tDnHkpZBczlAiZWSNUOW2qwTllBuyTTW/FZWSp5nFrPj+NQszJrfe312fuU460Uj9S+mS17s/Ox7YDsB4ZuiZV/b0XuxGPUzYKGrMsN+vou4rSqi0JvG+fdMzSL2urmfB1CZMdLd8SY4UC/qAJt0l5whM/+OX+/68pXtQ=", + "iv_hex": "BD58957502A80412410CE2D10EA92645" + }, + { + "encryptionType": 0, + "data_base64": "sLJQjd75xrxDL+UrMzA8ocFRTjxvJbf2kYcLsUSVDCvivxUwfm/amHEeYPlVFELrq8e3aZKmtkIz9q4Lry2JqM7A5gxMN4mUZp3SuWqWoWt+maMX7oAa/H8BE/HQbl15r905C1AilNtGdSFRllIqtLUzmaHjDIcBy6j5hYxqYagblmAm/NOpQFawakjiRPI10PgMAzoU8lfej25Zte0wb4aCNuuyPDl+nHGlk8DVvCQcBI/Ea3Brf/2fzkefLWB4Nz9z3wUmtaNGNG09bhlzp5n7RIsOAUL2GNywFD+ca2ozCLDOgEPY3e/8yRnsRhwG49vs14fkumHDd/XaumMm1gSzKCTzMtcQ13+I8ZuTIkYeze3Dr01Fly9j8rR3o3/hYGKSPz+XP3liRpjsbOrQuXZgYWZP9Q4UOjtNyL9tBIM=", + "iv_hex": "6FBFB8D9C55DCCD23151E2CB54D995F7" + }, + { + "encryptionType": 0, + "data_base64": "tWeqjgPibTx+3/XC483pRi2BJjL60q2OlwTkgsBC+3G/zcZ7CAAr+Aj/dDtX1B5wiyjLVcB4cgNzH2HI7GjurPvQBJV2THCBbe/2DRX2SH1lOiEAQrZyULZrVTebcyaC18GcC8mBNoSUX/ezDOBc33TAOgNYgssw78cP51F7oD/B7wGelxsHlEkYduUwm5t/sekRQ26ffg7549CkmFtg56YKGOZrh6xpok0MpzWAd84PfTUNBBLsPB3k3Oja2blruuA6O3Mc1qI0/aPPYympqmwDhq5vdKDhP5InJIvUwr1hiF4cgDQW0w7VIorshPoaWY7VNnt8cVsEux8jzOr/frdNpm2lQWYFa6YZG7WjfnKUzaYXUpndfCW9bkNjdM0FErfSShfFVtJn4RhMDiQuXQ==", + "iv_hex": "590C2DEC3AFAFE5A902236EB7617D68C" + }, + { + "encryptionType": 0, + "data_base64": "LCr1XNWRkVCDn1QAZP1MkOis3vlV6mAGZYuRbqRaJL2SaAGi61xRKyF93kwmeh9gr/Ug+MM4DQbjES/9wnZK/L/qZFxTsOaP4KcWfT1jAAgH+hP1yKSgcRZTxx13BWRPUQ6BCVdkUmOr7bWcXs1u9ZSpL4EKcKaBtjiUPjVbk/oP+G4qJAYcOW0Bk6Lz7vrZC30b+PdGxTbLWYUpR+vY9NYSUBYR4C0El9O3VQqqFoPlsJVNa7/se3pR7/gf1ha8jZuPZjUM6r1+8+4T8O+XIl9zwlfGyBJU5PIEglnQRGg1XB1GQ5CqFmzl6LiqbJ+XurkX9KAzND9NrpsFBq5SAXWcXu+NKPx8mCYJ0Nj4PRS73brvpKCjTGlv6JlgCVK0PrPvx++UStrRR9UX4e3POw==", + "iv_hex": "93E5657F0FD7794924494EF7EB2C99B0" + }, + { + "encryptionType": 0, + "data_base64": "k2trD1mxGcR+JoscazSv4cjHUYhx7ZSQWnpoqsd2fTL13eU/fvpQkjnwsw/6I9R/YYXsYuv5uN23EpwjeWSkZxs2Dv8uaXtfHB0PGz1aicssL1U5ctJjjc0NunTLRpWsHM2wwI6MV2hKEEmhVHnV66t6nPypmgxuAam9uEwaTaI+qsTxiUF4zRuQBi5p83Nk4jI0R6yUXVOXK+72eBTGz3ukiypCg4EawwK2C9oC1LpcN4zVkt20Lxsi4NtAy2Qj7GW568h3+SY+8oqWSgyHusY1rYNA4+xPnQ6ftwhPjYbMm7+CGATJ/KOj8ihiCbAOrObcQAonGUWvyTFMq0hNlL39X2j6uZS0rHmlLINerW5XW0ZpZhk+mmPZMO0ycilEiOk/hdFYsnIxLcxBiHvjDQ==", + "iv_hex": "0C49F64B522C9212464EF0EFCC0CBE03" + } + ], + "vouchers": [] + }, + "username": "bob" + } +} diff --git a/test/testpartner.ts b/test/testpartner.ts index b3823293..fdb74dbe 100644 --- a/test/testpartner.ts +++ b/test/testpartner.ts @@ -15,6 +15,7 @@ import { import fs from 'fs' import edgeExchangePlugins from '../src' +import { arrrCurrencyInfo } from './fakeArrrInfo' import { avaxCurrencyInfo } from './fakeAvaxInfo' import { btcCurrencyInfo } from './fakeBtcInfo' import { makeFakePlugin } from './fakeCurrencyPlugin' @@ -41,6 +42,7 @@ async function main(): Promise { bitcoin: makeFakePlugin(btcCurrencyInfo), ethereum: makeFakePlugin(ethCurrencyInfo), avalanche: makeFakePlugin(avaxCurrencyInfo), + piratechain: makeFakePlugin(arrrCurrencyInfo), ...edgeExchangePlugins } @@ -61,7 +63,12 @@ async function main(): Promise { bitcoin: true, ethereum: true, avalanche: true, - thorchainda: true + piratechain: true, + thorchainda: true, + changelly: { + apiKey: '', + secret: '' + } } }) @@ -69,10 +76,12 @@ async function main(): Promise { const btcInfo = await account.getFirstWalletInfo('wallet:bitcoin') const ethInfo = await account.getFirstWalletInfo('wallet:ethereum') const avaxInfo = await account.getFirstWalletInfo('wallet:avalanche') + const arrrInfo = await account.getFirstWalletInfo('wallet:piratechain') const btcWallet = await account.waitForCurrencyWallet(btcInfo?.id ?? '') const ethWallet = await account.waitForCurrencyWallet(ethInfo?.id ?? '') const avaxWallet = await account.waitForCurrencyWallet(avaxInfo?.id ?? '') + const arrrWallet = await account.waitForCurrencyWallet(arrrInfo?.id ?? '') // Test a FROM quote const fromRequest: EdgeSwapRequest = { @@ -93,6 +102,44 @@ async function main(): Promise { ) console.log(`------------`) + // Test a FROM ARRR to BTC quote + const fromRequest2: EdgeSwapRequest = { + fromWallet: arrrWallet, + fromCurrencyCode: 'ARRR', + toWallet: btcWallet, + toCurrencyCode: 'BTC', + nativeAmount: await arrrWallet.denominationToNative('109', 'ARRR'), + quoteFor: 'from' + } + console.log(`fromRequest2:`) + console.log( + JSON.stringify( + { ...fromRequest2, fromWallet: undefined, toWallet: undefined }, + null, + 2 + ) + ) + console.log(`------------`) + + // Test a FROM BTC to ARRR quote + const fromRequest3: EdgeSwapRequest = { + fromWallet: btcWallet, + fromCurrencyCode: 'BTC', + toWallet: arrrWallet, + toCurrencyCode: 'ARRR', + nativeAmount: await btcWallet.denominationToNative('0.01', 'BTC'), + quoteFor: 'from' + } + console.log(`fromRequest3:`) + console.log( + JSON.stringify( + { ...fromRequest3, fromWallet: undefined, toWallet: undefined }, + null, + 2 + ) + ) + console.log(`------------`) + // Test a TO quote const toRequest: EdgeSwapRequest = { fromWallet: ethWallet, @@ -111,7 +158,7 @@ async function main(): Promise { ) ) - const quote = await account.fetchSwapQuote(fromRequest).catch(e => { + const quote = await account.fetchSwapQuote(fromRequest2).catch(e => { console.log(e) console.log(e.message) }) From 3c83d1bbec5a8262012b2bcbb6b8d44b74516b4a Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Tue, 3 Jan 2023 22:39:13 -0800 Subject: [PATCH 4/4] Dont use legacy addresses --- src/swap/changehero.ts | 10 ++-------- src/swap/changenow.ts | 10 ++-------- src/swap/exolix.ts | 13 ++----------- src/swap/godex.ts | 10 ++-------- src/swap/letsexchange.ts | 10 ++-------- src/swap/swapuz.ts | 10 ++-------- 6 files changed, 12 insertions(+), 51 deletions(-) diff --git a/src/swap/changehero.ts b/src/swap/changehero.ts index 5fad531c..6aa5b97f 100644 --- a/src/swap/changehero.ts +++ b/src/swap/changehero.ts @@ -82,18 +82,12 @@ const asCreateFixTransactionReply = asObject({ }) }) -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ currencyCode }) - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } function checkReply( diff --git a/src/swap/changenow.ts b/src/swap/changenow.ts index fdddf118..1525b191 100644 --- a/src/swap/changenow.ts +++ b/src/swap/changenow.ts @@ -46,10 +46,6 @@ const asInitOptions = asObject({ const orderUri = 'https://changenow.io/exchange/txs/' const uri = 'https://api.changenow.io/v2/' -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { from: {}, to: { @@ -66,10 +62,8 @@ async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ currencyCode }) - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } export function makeChangeNowPlugin( diff --git a/src/swap/exolix.ts b/src/swap/exolix.ts index 54740e9a..95761965 100644 --- a/src/swap/exolix.ts +++ b/src/swap/exolix.ts @@ -53,10 +53,6 @@ const uri = 'https://exolix.com/api/' const expirationMs = 1000 * 60 -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - const asRateResponse = asObject({ min_amount: asString }) @@ -73,13 +69,8 @@ async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ - currencyCode - }) - - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } export function makeExolixPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin { diff --git a/src/swap/godex.ts b/src/swap/godex.ts index d045d3d4..96765b5d 100644 --- a/src/swap/godex.ts +++ b/src/swap/godex.ts @@ -68,10 +68,6 @@ const asQuoteInfo = asObject({ return_extra_id: asEither(asString, asNull) }) -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { from: { ethereum: ['MATIC'], @@ -102,10 +98,8 @@ async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ currencyCode }) - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } export function makeGodexPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin { diff --git a/src/swap/letsexchange.ts b/src/swap/letsexchange.ts index e1edf207..6ebf661b 100644 --- a/src/swap/letsexchange.ts +++ b/src/swap/letsexchange.ts @@ -56,10 +56,6 @@ const asInfoReply = asObject({ max_amount: asString, amount: asString }) -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { from: {}, to: { @@ -80,10 +76,8 @@ async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ currencyCode }) - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } export function makeLetsExchangePlugin( diff --git a/src/swap/swapuz.ts b/src/swap/swapuz.ts index 67607728..0b60ff85 100644 --- a/src/swap/swapuz.ts +++ b/src/swap/swapuz.ts @@ -47,10 +47,6 @@ const asInitOptions = asObject({ const orderUri = 'https://swapuz.com/order/' const uri = 'https://api.swapuz.com/api/home/v1/' -const dontUseLegacy: { [cc: string]: boolean } = { - DGB: true -} - const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { from: {}, to: { @@ -67,10 +63,8 @@ async function getAddress( wallet: EdgeCurrencyWallet, currencyCode: string ): Promise { - const addressInfo = await wallet.getReceiveAddress({ currencyCode }) - return addressInfo.legacyAddress != null && !dontUseLegacy[currencyCode] - ? addressInfo.legacyAddress - : addressInfo.publicAddress + const { publicAddress } = await wallet.getReceiveAddress({ currencyCode }) + return publicAddress } export function makeSwapuzPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {