Feat: Changelly integration#449
Conversation
Signed-off-by: Changelly <[email protected]>
Signed-off-by: Changelly <[email protected]>
| toCurrencyCode | ||
| } = getCodesWithTranscription(request, MAINNET_CODE_TRANSCRIPTION) | ||
|
|
||
| const fromTicker = |
There was a problem hiding this comment.
getCodesWithTranscription() is the wrong abstraction for this integration. That helper is useful for providers that model assets as separate chainCode + tokenCode values and mostly key off currency codes. Changelly does not work that way here. It exposes a single provider asset id per supported asset, and this PR only passes the mainnet transcription map, so the returned Changelly IDs would land in fromMainnetCode / toMainnetCode anyway. The quote path never uses those values, so the mapped Changelly IDs are effectively ignored.
There is a second problem in the same area: falling back to fromCurrencyCode.toLowerCase() / toCurrencyCode.toLowerCase() when the asset is not found in the provider cache is unsafe. If the cache lookup misses, the plugin can silently request a quote for a different asset than the one the user selected. ETH is the obvious example, since many distinct chains use that currency code.
A better approach would be to build the cache as a mapping from Changelly-supported assets to local pluginId / tokenId pairs using the provider payload, especially contractAddress. Convert the Changelly supported assets response to a ChainCodeTickerMap and then use that with the getChainAndTokenCodes utility. Using the returned fromCurrencyCode and toCurrencyCode from that function would result in the correct Changelly IDs for the quote. Changehero, Changenow, Letsexchange, and Sideshift have all adopted this pattern.
| if (profiles.length === 0) throw new Error('Unable to detect user params') | ||
|
|
||
| return { | ||
| userId: profiles[0].userId, |
There was a problem hiding this comment.
Let's use initOptions (passed in via EdgeCorePluginOptions) instead of using disklet. We can pass in any arbitrary fields necessary.
There was a problem hiding this comment.
These options are integral to our new 'relay' strategy. We have opted to bypass endpoint authentication via provided credentials in favor of authenticating edge users through non-sensitive data stored locally(zero-config authentication).
There was a problem hiding this comment.
The data accessed in this blob are unique to the user and don't identify them as Edge users. Also, it passes the username of any account that attempts a swap to Changelly, which is non-starter. We don't associate usernames with swaps and won't pass them along. Instead, ignore the local disklet completely and accept the same string the Changelly reports-server PR is expecting "edge-app".
Signed-off-by: Changelly <[email protected]>
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
PR's contains no dependencies.
Description
PR introduces new Changelly Relay API matching the actual JSON-RPC envelope.