Skip to content

Commit

Permalink
Add special mainnet case for ChangeNow
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Feb 27, 2024
1 parent da879fb commit 952d612
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

- added: (Swapuz) Above limit response handling
- added: (ChangeNow) AVAX special mainnet case
- fixed: (Exolix) Correctly handle below limit errors for 'from' quotes
- fixed: (Godex/Swapuz) Fix conversion to native units

## 2.1.0 (2023-02-09)

- added: Mainnet codes for Arbitrum, Axelar, Base, and Cosmos Hub
Expand Down
19 changes: 17 additions & 2 deletions src/swap/central/changenow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EdgeSwapPlugin,
EdgeSwapQuote,
EdgeSwapRequest,
EdgeTokenId,
SwapAboveLimitError,
SwapBelowLimitError,
SwapCurrencyError
Expand Down Expand Up @@ -119,6 +120,12 @@ const MAINNET_CODE_TRANSCRIPTION = {
zksync: 'zksync'
}

const SPECIAL_MAINNET_CASES: {
[pId: string]: Map<EdgeTokenId, string>
} = {
avalanche: new Map([[null, 'cchain']])
}

export function makeChangeNowPlugin(
opts: EdgeCorePluginOptions
): EdgeSwapPlugin {
Expand Down Expand Up @@ -147,9 +154,17 @@ export function makeChangeNowPlugin(
const {
fromCurrencyCode,
toCurrencyCode,
fromMainnetCode,
toMainnetCode
fromMainnetCode: defaultFromMainnetCode,
toMainnetCode: defaultToMainnetCode
} = getCodesWithTranscription(request, MAINNET_CODE_TRANSCRIPTION)
const fromMainnetCode =
SPECIAL_MAINNET_CASES[request.fromWallet.currencyInfo.pluginId]?.get(
request.fromTokenId
) ?? defaultFromMainnetCode
const toMainnetCode =
SPECIAL_MAINNET_CASES[request.toWallet.currencyInfo.pluginId]?.get(
request.toTokenId
) ?? defaultToMainnetCode
const currencyString = `fromCurrency=${fromCurrencyCode}&toCurrency=${toCurrencyCode}&fromNetwork=${fromMainnetCode}&toNetwork=${toMainnetCode}`

async function createOrder(
Expand Down

0 comments on commit 952d612

Please sign in to comment.